@layer base, components, utilities;

@layer base {
    :root {
        --primary: oklch(0.6 0.2 250);
        --accent: oklch(0.7 0.15 30);
        --text: oklch(0.2 0.02 250);
        --bg: oklch(0.98 0.01 250);
        --surface: oklch(1 0 0);
        --shadow: 0 10px 40px -10px oklch(0 0 0 / 0.08);
        --font-body: 'Inter', system-ui, sans-serif;
        --font-heading: 'Playfair Display', serif;
    }

    * {
        box-sizing: border-box;
    }

    body {
        font-family: var(--font-body);
        margin: 0;
        background-color: var(--bg);
        color: var(--text);
        line-height: 1.6;
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.02'/%3E%3C/svg%3E");
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
}

@layer components {
    header {
        padding: 4rem 2rem 2rem;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        max-width: 1200px;
        width: 100%;
        margin: 0 auto;
    }

    .header-content h1 {
        font-family: var(--font-heading);
        font-size: 3rem;
        margin: 0 0 0.5rem 0;
        background: linear-gradient(to right, var(--primary), var(--accent));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    #live-clock {
        font-size: 1.5rem;
        font-weight: 600;
        color: var(--primary);
    }

    #live-date {
        font-size: 1rem;
        opacity: 0.6;
    }

    #lang-toggle {
        padding: 0.5rem 1rem;
        border: 1px solid oklch(0.8 0 0);
        background: var(--surface);
        border-radius: 50px;
        cursor: pointer;
        font-weight: 600;
        transition: all 0.2s;
    }

    #lang-toggle:hover {
        background: oklch(0.95 0 0);
    }

    #main-tabs {
        display: flex;
        gap: 1rem;
        padding: 0 2rem;
        max-width: 1200px;
        width: 100%;
        margin: 0 auto 2rem;
    }

    .tab-btn {
        padding: 1rem 2rem;
        border: none;
        background: var(--surface);
        border-radius: 16px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        box-shadow: var(--shadow);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        font-family: var(--font-body);
        font-weight: 600;
    }

    .tab-btn .icon {
        font-size: 1.2rem;
    }

    .tab-btn.active {
        background: var(--primary);
        color: white;
        transform: translateY(-4px);
        box-shadow: 0 20px 40px -10px oklch(0.6 0.2 250 / 0.3);
    }

    #dashboard-content {
        flex-grow: 1;
        padding: 0 2rem 4rem;
        max-width: 1200px;
        width: 100%;
        margin: 0 auto;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 2rem;
    }

    .dash-card {
        background: var(--surface);
        padding: 2rem;
        border-radius: 24px;
        box-shadow: var(--shadow);
        transition: transform 0.3s;
    }

    .dash-card:hover {
        transform: translateY(-5px);
    }

    .dash-card h3 {
        margin: 0 0 1.5rem 0;
        font-family: var(--font-heading);
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .link-list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: grid;
        gap: 1rem;
    }

    .link-item a {
        display: block;
        padding: 1rem;
        background: var(--bg);
        border-radius: 12px;
        text-decoration: none;
        color: var(--text);
        font-weight: 500;
        transition: all 0.2s;
        border-left: 4px solid transparent;
    }

    /* Saju Form Styles */
    .saju-form-content {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    .input-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .input-group label {
        font-size: 0.9rem;
        font-weight: 600;
        opacity: 0.8;
    }

    .input-group input[type="date"],
    .input-group select {
        padding: 0.75rem;
        border-radius: 12px;
        border: 1px solid oklch(0.9 0 0);
        background: var(--bg);
        font-family: var(--font-body);
    }

    .radio-group {
        flex-direction: row;
        gap: 1.5rem;
        align-items: center;
        padding: 0.5rem 0;
    }

    .radio-group label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
    }

    .primary-btn {
        padding: 1rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 16px;
        font-weight: 700;
        cursor: pointer;
        box-shadow: 0 10px 20px -5px oklch(0.6 0.2 250 / 0.3);
        transition: all 0.2s;
    }

    .primary-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 15px 30px -10px oklch(0.6 0.2 250 / 0.4);
    }

    .primary-btn:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    /* Saju Result Styles */
    .saju-result-container {
        margin-top: 2rem;
        padding-top: 2rem;
        border-top: 1px solid oklch(0.9 0 0);
        animation: fadeIn 0.5s ease-out;
    }

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

    .saju-eight-chars {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
        margin-bottom: 2rem;
    }

    .char-box {
        background: var(--bg);
        padding: 1rem;
        border-radius: 16px;
        text-align: center;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        border: 1px solid oklch(0.9 0 0);
    }

    .pillar {
        font-size: 0.75rem;
        font-weight: 600;
        opacity: 0.5;
    }

    .ganji {
        font-family: var(--font-heading);
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--primary);
    }

    .fortune-report {
        background: oklch(0.98 0.02 250);
        padding: 1.5rem;
        border-radius: 20px;
        margin-bottom: 1.5rem;
    }

    .fortune-report h4 {
        margin: 0 0 1rem 0;
        font-family: var(--font-heading);
        font-size: 1.25rem;
    }

    .fortune-report p {
        margin: 0;
        line-height: 1.7;
    }

    .recommendations {
        display: grid;
        gap: 1rem;
    }

    .rec-item {
        display: flex;
        gap: 1.5rem;
        align-items: center;
        padding: 1.25rem;
        background: var(--surface);
        border: 1px solid oklch(0.95 0 0);
        border-radius: 16px;
        box-shadow: var(--shadow);
    }

    .rec-icon {
        font-size: 2rem;
    }

    .rec-text strong {
        display: block;
        margin-bottom: 0.25rem;
        color: var(--primary);
    }

    .rec-text p {
        margin: 0;
        font-size: 0.9rem;
        opacity: 0.8;
    }

    /* Widget Styles */
    .widget-content {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    textarea#quick-note {
        width: 100%;
        height: 150px;
        border: 1px solid oklch(0.9 0 0);
        border-radius: 12px;
        padding: 1rem;
        font-family: var(--font-body);
        resize: none;
        background: var(--bg);
    }

    textarea#quick-note:focus {
        outline: none;
        border-color: var(--primary);
    }

    /* Image Converter Styles */
    .image-converter-content {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .drop-zone {
        border: 3px dashed oklch(0.85 0.01 250);
        border-radius: 20px;
        padding: 3rem;
        text-align: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .drop-zone p {
        margin: 0;
        font-weight: 500;
        color: oklch(0.6 0.02 250);
    }

    .drop-zone.dragging,
    .drop-zone:hover {
        background-color: oklch(0.97 0.01 250);
        border-color: var(--primary);
    }

    #file-list {
        margin-top: 1rem;
    }

    #file-list ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    #file-list li {
        background: var(--bg);
        padding: 0.75rem 1.25rem;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        color: var(--text);
    }


    .conversion-options {
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    #conversion-format {
        flex-grow: 1;
        padding: 0.75rem 1rem;
        border-radius: 12px;
        border: 1px solid oklch(0.9 0 0);
        background: var(--bg);
        font-family: var(--font-body);
        font-size: 1rem;
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%23666'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 1rem center;
        background-size: 1.2em;
    }

    #conversion-format:focus {
        outline: none;
        border-color: var(--primary);
    }

    #convert-btn {
        padding: 0.75rem 1.5rem;
        background-color: var(--primary);
        color: white;
        border: none;
        border-radius: 12px;
        font-weight: 600;
        cursor: pointer;
        transition: background-color 0.3s;
    }

    #convert-btn:hover {
        background-color: oklch(0.5 0.2 250);
    }

    #conversion-status {
        margin-top: 1rem;
        font-weight: 500;
        color: var(--primary);
    }

    /* Text Tools Styles */
    .text-tools-content {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    textarea#text-input {
        width: 100%;
        height: 500px;
        border: 1px solid oklch(0.9 0 0);
        border-radius: 16px;
        padding: 1.25rem;
        font-family: var(--font-body);
        font-size: 1rem;
        resize: none;
        background: var(--bg);
        transition: border-color 0.2s;
    }

    textarea#text-input:focus {
        outline: none;
        border-color: var(--primary);
    }

    .text-stats {
        display: flex;
        gap: 2rem;
        padding: 1rem;
        background: oklch(0.97 0.01 250);
        border-radius: 12px;
    }

    .stat-item {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .stat-label {
        font-size: 0.8rem;
        font-weight: 600;
        opacity: 0.6;
    }

    #char-count-all, #char-count-no-space {
        font-size: 1.25rem;
        font-weight: 700;
        color: var(--primary);
    }

    .text-actions {
        display: flex;
        gap: 1rem;
    }

    .text-actions button {
        flex: 1;
        padding: 0.75rem;
        border-radius: 12px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
    }

    #spell-check-btn {
        background: var(--primary);
        border: none;
        color: white;
    }

    #spell-check-btn:hover {
        background: oklch(0.5 0.2 250);
    }

    #text-tool-status {
        font-size: 0.9rem;
        color: var(--accent);
        font-weight: 500;
        height: 1.2em;
    }

    /* Settings Gear Button */
    .settings-btn {
        padding: 0.5rem 1.25rem;
        border: 1px solid oklch(0.85 0 0);
        background: var(--surface);
        border-radius: 50px;
        cursor: pointer;
        font-weight: 600;
        font-family: var(--font-body);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        align-items: center;
        gap: 0.35rem;
        box-shadow: var(--shadow);
    }
    .settings-btn:hover {
        background: oklch(0.97 0 0);
        transform: translateY(-1px);
        border-color: var(--primary);
    }

    /* Fallback Warning Box */
    .saju-fallback-notice {
        margin-top: 1.25rem;
        background: oklch(0.98 0.01 50 / 0.8);
        border-left: 4px solid var(--accent);
        border-radius: 12px;
        padding: 1rem;
        font-size: 0.85rem;
        line-height: 1.5;
        color: oklch(0.3 0.02 50);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .saju-fallback-notice a {
        color: var(--primary);
        font-weight: bold;
        text-decoration: underline;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1.5rem;
        padding-top: 2rem;
    }
    .header-content h1 {
        font-size: 2rem;
    }
    #main-tabs {
        flex-direction: column;
    }
}
