/* ============================================================
   KỲ MÔN ĐỘN GIÁP — Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

.kmdg-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* ========== HEADER ========== */
.kmdg-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 50px 20px;
    background: linear-gradient(135deg, #1a0a2e 0%, #2d1b4e 30%, #4a1942 60%, #1a0a2e 100%);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.kmdg-header::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(212,175,55,0.08) 0%, transparent 60%);
    animation: kmdg-rotate 25s linear infinite;
}

.kmdg-header::after {
    content: '奇門遁甲';
    position: absolute;
    bottom: 15px; right: 25px;
    font-size: 14px;
    color: rgba(255,255,255,0.12);
    letter-spacing: 4px;
}

@keyframes kmdg-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.kmdg-logo-img {
    width: 90px; height: 90px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
    position: relative; z-index: 1;
    box-shadow: 0 0 30px rgba(212,175,55,0.5);
    border: 3px solid rgba(212,175,55,0.6);
    animation: kmdg-pulse 3s ease-in-out infinite;
}

@keyframes kmdg-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(212,175,55,0.5); }
    50% { transform: scale(1.04); box-shadow: 0 0 45px rgba(212,175,55,0.7); }
}

.kmdg-title {
    font-family: 'Playfair Display', serif;
    font-size: 34px;
    font-weight: 700;
    color: #d4af37;
    margin: 10px 0 5px;
    position: relative; z-index: 1;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.kmdg-tagline {
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    position: relative; z-index: 1;
    margin: 0;
    letter-spacing: 2px;
}

/* ========== INTRO ========== */
.kmdg-intro {
    background: linear-gradient(135deg, #fdf8f0, #f8f4ec);
    border-left: 4px solid #4a1942;
    padding: 25px 30px;
    margin-bottom: 30px;
    border-radius: 0 12px 12px 0;
    font-size: 14.5px;
    line-height: 1.85;
    color: #333;
}

.kmdg-intro strong { color: #4a1942; }
.kmdg-intro p:last-child { margin-bottom: 0; }

/* ========== TABS ========== */
.kmdg-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    background: #2d1b4e;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}

.kmdg-tab {
    flex: 1;
    padding: 14px 10px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.5px;
}

.kmdg-tab:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}

.kmdg-tab.active {
    background: #e8740c;
    color: white;
    box-shadow: 0 2px 10px rgba(232,116,12,0.4);
}

/* ========== FORM ========== */
.kmdg-form-section {
    background: #fff;
    border: 1px solid #e0e4e8;
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.kmdg-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.kmdg-form-group {
    flex: 1;
    min-width: 120px;
}

.kmdg-form-group.kmdg-full {
    flex: 1 0 100%;
}

.kmdg-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kmdg-form-group label small {
    text-transform: none;
    font-weight: 400;
    color: #999;
}

.kmdg-input {
    width: 100%;
    box-sizing: border-box;
    height: 46px;
    padding: 0 14px;
    border: 2px solid #e0e4e8;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s;
    background: #fafbfc;
}

.kmdg-input:focus {
    border-color: #4a1942;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74,25,66,0.1);
    background: #fff;
}

.kmdg-btn-group {
    min-width: 190px;
}

.kmdg-btn-row {
    display: flex;
    gap: 6px;
}

.kmdg-btn-now {
    flex: 1;
    height: 46px;
    border: 2px solid #4a1942;
    background: transparent;
    color: #4a1942;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.kmdg-btn-now:hover {
    background: #4a1942;
    color: white;
}

.kmdg-btn-adjust {
    width: 46px;
    height: 46px;
    border: 2px solid #e0e4e8;
    background: #fff;
    color: #555;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.kmdg-btn-adjust:hover {
    border-color: #4a1942;
    color: #4a1942;
}

.kmdg-form-actions {
    text-align: center;
    margin-top: 5px;
}

.kmdg-btn-lap {
    background: linear-gradient(135deg, #e8740c, #d4630a);
    color: white;
    border: none;
    padding: 15px 50px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(232,116,12,0.35);
}

.kmdg-btn-lap:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(232,116,12,0.5);
}

.kmdg-btn-lap:active {
    transform: translateY(0);
}

/* ========== FOUR PILLARS ========== */
.kmdg-pillars {
    margin-bottom: 20px;
}

.kmdg-pillars-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 2px solid #e8740c;
    border-radius: 8px;
    overflow: hidden;
}

.kmdg-pillars-table th {
    background: #e8740c;
    color: white;
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.kmdg-can-cell {
    text-align: center;
    padding: 12px;
    font-size: 22px;
    font-weight: 700;
    color: #4a1942;
    border-bottom: 1px solid #f0e8e0;
}

.kmdg-chi-cell {
    text-align: center;
    padding: 12px;
    font-size: 22px;
    font-weight: 700;
    color: #e8740c;
}

.kmdg-label-cell {
    font-size: 12px;
    color: #999;
    text-align: center;
    padding: 8px;
    background: #fdf8f0;
    white-space: nowrap;
}

/* ========== INFO BAR ========== */
.kmdg-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #2d1b4e, #4a1942);
    padding: 16px 20px;
    border-radius: 10px;
}

.kmdg-info-item {
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.kmdg-info-label {
    display: block;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.kmdg-info-value {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #d4af37;
}

.kmdg-cuc-value {
    font-size: 15px;
    color: #ff9500;
}

/* ========== CỬU CUNG GRID ========== */
.kmdg-cuu-cung-wrapper {
    margin-bottom: 20px;
}

.kmdg-direction-top, .kmdg-direction-bottom {
    text-align: center;
    font-size: 13px;
    color: #888;
    padding: 6px 0;
    letter-spacing: 4px;
}

.kmdg-cung-container {
    display: flex;
    align-items: stretch;
}

.kmdg-direction-left, .kmdg-direction-right {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    font-size: 13px;
    color: #888;
    padding: 0 10px;
    text-align: center;
    line-height: 1.8;
}

.kmdg-grid-3x3 {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border: 3px solid #4a1942;
    border-radius: 4px;
    overflow: hidden;
}

/* ========== PALACE CELL ========== */
.kmdg-palace {
    border: 1px solid #d4c4a0;
    padding: 10px 8px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(180deg, #fffcf4, #fff8ec);
    position: relative;
    transition: all 0.3s;
}

.kmdg-palace:hover {
    background: linear-gradient(180deg, #fff5dd, #ffedcc);
    z-index: 2;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

.kmdg-palace-kw {
    background: linear-gradient(180deg, #f5f0f0, #ece5e5) !important;
    opacity: 0.8;
}

.kmdg-palace-center {
    background: linear-gradient(135deg, #fdf2e0, #f8e8d0) !important;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.kmdg-center-can {
    font-size: 36px;
    font-weight: 700;
    color: #4a1942;
}

.kmdg-center-label {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
}

.kmdg-center-time {
    font-size: 12px;
    color: #e8740c;
    font-weight: 600;
    margin-top: 3px;
}

/* Palace content */
.kmdg-p-deity {
    font-size: 11px;
    color: #7b2d8e;
    font-weight: 600;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.kmdg-p-main {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 4px 0;
}

.kmdg-p-star {
    font-size: 16px;
    font-weight: 700;
    color: #c0392b;
}

.kmdg-p-gate {
    font-size: 18px;
    font-weight: 700;
    color: #27ae60;
}

.kmdg-p-cans {
    display: flex;
    justify-content: space-around;
    margin: 4px 0;
}

.kmdg-p-tcan {
    font-size: 14px;
    font-weight: 600;
    color: #2980b9;
}

.kmdg-p-dcan {
    font-size: 14px;
    font-weight: 600;
    color: #8b6914;
}

.kmdg-p-footer {
    font-size: 10px;
    color: #888;
    text-align: center;
    border-top: 1px solid #e8dcc8;
    padding-top: 4px;
    margin-top: 4px;
}

.kmdg-p-trigram {
    font-size: 13px;
}

.kmdg-p-number {
    font-weight: 700;
    color: #4a1942;
}

.kmdg-kw-badge {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 700;
}

/* ========== PHONE BAR ========== */
.kmdg-phone-bar {
    text-align: center;
    padding: 10px;
    background: #fdf8f0;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

.kmdg-phone-bar a {
    color: #e8740c;
    font-weight: 700;
    text-decoration: none;
}

/* ========== INTERPRETATION ========== */
.kmdg-interpretation {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.kmdg-interpretation h3 {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    color: #4a1942;
    margin: 0 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0e8e0;
}

.kmdg-interpretation h4 {
    font-size: 16px;
    color: #4a1942;
    margin: 18px 0 8px;
}

.kmdg-interp-item {
    font-size: 14px;
    line-height: 1.7;
    color: #444;
    margin: 4px 0;
    padding-left: 10px;
}

.kmdg-interp-item strong {
    color: #4a1942;
}

/* ========== RAW TEXT ========== */
.kmdg-rawtext {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.kmdg-rawtext h3 {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    color: #4a1942;
    margin: 0 0 8px;
}

.kmdg-rawtext-desc {
    font-size: 13px;
    color: #888;
    margin-bottom: 15px;
}

.kmdg-rawtext-box {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    font-size: 13px;
    line-height: 1.8;
    color: #333;
    font-family: monospace;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.kmdg-btn-copy {
    background: #4a1942;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.kmdg-btn-copy:hover {
    background: #6b2a63;
    transform: translateY(-1px);
}

/* ========== FOOTER ========== */
.kmdg-footer {
    text-align: center;
    padding: 25px;
    margin-top: 30px;
    border-top: 2px solid #f0e8e0;
    color: #888;
    font-size: 13px;
}

.kmdg-phone {
    margin-top: 5px;
}

.kmdg-phone a {
    color: #e8740c;
    font-weight: 700;
    text-decoration: none;
    font-size: 16px;
}

/* ========== KNOWLEDGE SECTION ========== */
.kmdg-learn-section {
    margin-top: 40px;
    border-top: 3px solid #4a1942;
    padding-top: 30px;
}

.kmdg-learn-header {
    text-align: center;
    margin-bottom: 25px;
}

.kmdg-learn-header h3 {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    color: #4a1942;
    margin-bottom: 8px;
}

.kmdg-learn-header p {
    color: #888;
    font-size: 14px;
}

.kmdg-chapter {
    margin-bottom: 12px;
}

.kmdg-chapter-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    background: linear-gradient(135deg, #4a1942 0%, #2d1b4e 100%);
    color: #fff;
    border-radius: 10px;
    transition: all 0.3s;
    user-select: none;
    box-shadow: 0 2px 8px rgba(74,25,66,0.25);
}

.kmdg-chapter-header:hover {
    box-shadow: 0 4px 15px rgba(74,25,66,0.4);
    transform: translateY(-1px);
}

.kmdg-chapter-header.active {
    border-radius: 10px 10px 4px 4px;
}

.kmdg-chapter-icon {
    font-size: 24px;
    margin-right: 12px;
}

.kmdg-chapter-title {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
}

.kmdg-chapter-body {
    display: none;
    background: #f5f0f5;
    border-radius: 0 0 10px 10px;
    padding: 12px;
    animation: kmdg-slideIn 0.3s ease;
}

@keyframes kmdg-slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.kmdg-lesson-item {
    border: 1px solid #e5dde5;
    border-radius: 8px;
    margin-bottom: 6px;
    overflow: hidden;
}

.kmdg-lesson-toggle {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    background: #fff;
    transition: background 0.2s;
    user-select: none;
}

.kmdg-lesson-toggle:hover { background: #fdf8f0; }

.kmdg-lesson-toggle.active {
    background: #4a1942;
    color: white;
}

.kmdg-lesson-toggle.active .kmdg-lesson-title { color: white; }
.kmdg-lesson-toggle.active .kmdg-lesson-arrow { color: #d4af37; }

.kmdg-lesson-icon {
    font-size: 22px;
    margin-right: 12px;
    flex-shrink: 0;
}

.kmdg-lesson-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.kmdg-lesson-arrow {
    font-size: 16px;
    color: #999;
    margin-left: 10px;
    transition: transform 0.3s;
}

.kmdg-lesson-body {
    display: none;
    padding: 18px 22px;
    background: #fafbfc;
    border-top: 1px solid #e5dde5;
    font-size: 13.5px;
    line-height: 1.8;
    color: #444;
    animation: kmdg-slideIn 0.3s ease;
}

.kmdg-lesson-body h5 {
    font-size: 14px;
    color: #4a1942;
    margin: 14px 0 6px;
}

.kmdg-lesson-body ul, .kmdg-lesson-body ol {
    padding-left: 20px;
    margin: 8px 0;
}

.kmdg-lesson-body li { margin-bottom: 5px; }
.kmdg-lesson-body strong { color: #4a1942; }

.kmdg-lesson-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12.5px;
}

.kmdg-lesson-table th {
    background: #4a1942;
    color: white;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
}

.kmdg-lesson-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #e5dde5;
}

.kmdg-lesson-table tr:nth-child(even) td { background: #fdf8f0; }
.kmdg-lesson-table tr:hover td { background: #f5eff5; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .kmdg-tabs { flex-wrap: wrap; }
    .kmdg-tab { flex: 1 0 50%; font-size: 12px; padding: 12px 6px; }
    .kmdg-form-row { flex-direction: column; }
    .kmdg-form-group { min-width: 100%; }
    .kmdg-info-bar { gap: 8px; }
    .kmdg-info-item { min-width: 80px; }
    .kmdg-grid-3x3 { font-size: 11px; }
    .kmdg-palace { padding: 6px 4px; min-height: 90px; }
    .kmdg-p-star { font-size: 13px; }
    .kmdg-p-gate { font-size: 14px; }
    .kmdg-p-tcan, .kmdg-p-dcan { font-size: 12px; }
    .kmdg-center-can { font-size: 28px; }
    .kmdg-direction-left, .kmdg-direction-right { font-size: 11px; padding: 0 4px; }
    .kmdg-can-cell, .kmdg-chi-cell { font-size: 18px; padding: 8px; }
    .kmdg-pillars-table th { font-size: 12px; padding: 8px; }
}

@media (max-width: 480px) {
    .kmdg-wrapper { padding: 20px 10px; }
    .kmdg-title { font-size: 26px; }
    .kmdg-header { padding: 35px 15px; }
    .kmdg-palace { min-height: 75px; padding: 4px 3px; }
    .kmdg-p-deity { font-size: 9px; }
    .kmdg-p-star { font-size: 11px; }
    .kmdg-p-gate { font-size: 12px; }
    .kmdg-p-footer { font-size: 8px; }
    .kmdg-btn-lap { padding: 12px 30px; font-size: 15px; }
}
