* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;

    --background: #f5f7fb;
    --card: #ffffff;

    --text: #111827;
    --muted: #6b7280;

    --border: #e5e7eb;

    --success: #16a34a;
    --danger: #dc2626;

    --ai: #7c3aed;
    --ai-light: #f5f3ff;

    --radius: 16px;
}


/* ==========================================
   BASE
========================================== */

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;

    background: var(--background);
    color: var(--text);
}

button,
input {
    font-family: inherit;
}


/* ==========================================
   APP
========================================== */

.app {
    min-height: 100vh;
    display: flex;
}


/* ==========================================
   SIDEBAR
========================================== */

.sidebar {
    width: 330px;
    min-width: 330px;

    height: 100vh;

    position: sticky;
    top: 0;

    background: #ffffff;

    border-right:
        1px solid var(--border);

    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 22px 18px 16px;

    border-bottom:
        1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 13px;

    background: var(--primary);
    color: #ffffff;

    font-size: 21px;

    box-shadow:
        0 4px 10px
        rgba(37, 99, 235, .2);
}

.logo-title {
    font-size: 17px;
    font-weight: 700;
}

.logo-subtitle {
    margin-top: 2px;

    color: var(--muted);
    font-size: 12px;
}

.history-title {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-top: 25px;
    margin-bottom: 10px;

    color: #374151;

    font-size: 13px;
    font-weight: 700;
}

.history-count {
    min-width: 24px;
    padding: 3px 8px;

    border-radius: 20px;

    background: #f3f4f6;
    color: #6b7280;

    text-align: center;

    font-size: 11px;
    font-weight: 600;
}


/* ==========================================
   HISTÓRICO
========================================== */

.history {
    flex: 1;

    overflow-y: auto;

    padding: 10px 12px 20px;
}

.history::-webkit-scrollbar {
    width: 6px;
}

.history::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 20px;
}

.history-empty {
    padding: 35px 15px;

    color: var(--muted);

    text-align: center;

    font-size: 13px;
    line-height: 1.5;
}

.history-item {
    padding: 13px;

    margin-bottom: 7px;

    border: 1px solid transparent;
    border-radius: 12px;

    background: transparent;

    transition: .15s;
}

.history-item:hover {
    background: #f8fafc;
    border-color: var(--border);
}

.history-item.active {
    background: var(--primary-light);
    border-color: #bfdbfe;
}

.history-date {
    color: #374151;

    font-size: 13px;
    font-weight: 700;

    margin-bottom: 5px;
}

.history-preview {
    color: var(--muted);

    font-size: 12px;
    line-height: 1.45;

    display: -webkit-box;

    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

    overflow: hidden;
}

.history-actions {
    display: flex;
    gap: 6px;

    margin-top: 10px;
}

.history-actions button {
    border: 0;
    border-radius: 7px;

    padding: 6px 9px;

    font-size: 11px;
    font-weight: 600;

    cursor: pointer;

    transition: .15s;
}

.history-open {
    background: #f3f4f6;
    color: #374151;
}

.history-open:hover {
    background: #e5e7eb;
}

.history-analyze {
    background: #ede9fe;
    color: #6d28d9;
}

.history-analyze:hover {
    background: #ddd6fe;
}

.history-actions button:disabled {
    opacity: .6;
    cursor: wait;
}


/* ==========================================
   MAIN
========================================== */

.main {
    flex: 1;

    padding: 40px;

    overflow-y: auto;
}

.content {
    width: 100%;
    max-width: 950px;

    margin: 0 auto;
}

.header {
    margin-bottom: 25px;
}

.header h1 {
    margin: 0;

    font-size: 28px;
    letter-spacing: -.5px;
}

.header p {
    margin: 8px 0 0;

    color: var(--muted);
    font-size: 14px;
}


/* ==========================================
   CARD
========================================== */

.card {
    padding: 24px;

    background: var(--card);

    border:
        1px solid var(--border);

    border-radius: var(--radius);

    box-shadow:
        0 4px 20px
        rgba(15, 23, 42, .04);
}


/* ==========================================
   UPLOAD
========================================== */

.upload-area {
    display: block;

    padding: 42px 20px;

    border:
        2px dashed #bfdbfe;

    border-radius: 14px;

    background: #f8fbff;

    text-align: center;

    cursor: pointer;

    transition: .2s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area.uploading {
    border-color: var(--primary);
    background: var(--primary-light);

    pointer-events: none;
    cursor: wait;
}

.upload-icon {
    width: 54px;
    height: 54px;

    margin: 0 auto 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #dbeafe;
    color: var(--primary);

    font-size: 25px;
}

.upload-title {
    font-size: 15px;
    font-weight: 700;
}

.upload-description {
    margin-top: 7px;

    color: var(--muted);

    font-size: 13px;
}

.selected-file {
    margin-top: 12px;

    color: var(--primary);

    font-size: 13px;
    font-weight: 600;
}

input[type="file"] {
    display: none;
}


/* ==========================================
   BARRA DE PROGRESSO
========================================== */

.upload-progress {
    display: none;

    margin-top: 18px;
    padding: 16px;

    border: 1px solid #bfdbfe;
    border-radius: 12px;

    background: #f8fbff;
}

.upload-progress.show {
    display: block;
}

.upload-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    margin-bottom: 10px;
}

.upload-progress-title {
    display: flex;
    align-items: center;

    gap: 8px;

    font-size: 13px;
    font-weight: 700;

    color: #374151;
}

.upload-progress-percent {
    min-width: 48px;

    color: var(--primary);

    text-align: right;

    font-size: 18px;
    font-weight: 800;
}

.progress-bar {
    width: 100%;
    height: 10px;

    overflow: hidden;

    border-radius: 999px;

    background: #dbeafe;
}

.progress-fill {
    width: 0%;
    height: 100%;

    border-radius: inherit;

    background: linear-gradient(
        90deg,
        var(--primary),
        #60a5fa
    );

    transition: width .15s ease;
}

.upload-progress-info {
    display: flex;
    justify-content: space-between;

    gap: 10px;

    margin-top: 10px;

    color: var(--muted);

    font-size: 12px;
}

.upload-progress-status {
    margin-top: 8px;

    color: #374151;

    font-size: 12px;
    font-weight: 600;
}


/* ==========================================
   BUTTON
========================================== */

.button {
    width: 100%;

    margin-top: 18px;
    padding: 14px 18px;

    border: 0;
    border-radius: 11px;

    background: var(--primary);
    color: #ffffff;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;

    transition: .2s;
}

.button:hover {
    background: var(--primary-dark);
}

.button:disabled {
    opacity: .6;
    cursor: not-allowed;
}


/* ==========================================
   STATUS
========================================== */

#status {
    min-height: 20px;

    margin-top: 15px;

    font-size: 13px;
    font-weight: 600;
}

.sucesso {
    color: var(--success);
}

.erro {
    color: var(--danger);
}


/* ==========================================
   RESULTADO
========================================== */

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-top: 28px;
    margin-bottom: 10px;
}

.result-title {
    font-size: 15px;
    font-weight: 700;
}

.result-date {
    color: var(--muted);
    font-size: 12px;
}

#resultado {
    min-height: 240px;

    padding: 20px;

    border:
        1px solid var(--border);

    border-radius: 12px;

    background: #fafafa;

    color: #374151;

    font-size: 14px;
    line-height: 1.7;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.placeholder {
    color: #9ca3af;
}


/* ==========================================
   IA
========================================== */

.ai-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-top: 28px;
    margin-bottom: 10px;
}

.ai-title {
    display: flex;
    align-items: center;

    gap: 7px;

    color: #5b21b6;

    font-size: 15px;
    font-weight: 700;
}

.ai-status {
    color: var(--muted);
    font-size: 12px;
}

.ai-result {
    min-height: 300px;

    padding: 20px;

    border:
        1px solid #ddd6fe;

    border-radius: 12px;

    background: #fafaff;

    color: #374151;

    font-size: 14px;
    line-height: 1.7;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}


/* ==========================================
   MOBILE
========================================== */

@media (max-width: 800px) {

    .app {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-width: 0;

        height: auto;

        position: relative;

        border-right: 0;
        border-bottom:
            1px solid var(--border);
    }

    .sidebar-header {
        padding: 16px;
    }

    .history-title {
        margin-top: 18px;
    }

    .history {
        max-height: 280px;
    }

    .main {
        padding: 20px 14px;
    }

    .header h1 {
        font-size: 23px;
    }

    .card {
        padding: 16px;
    }

    .upload-area {
        padding: 35px 15px;
    }

    .upload-progress-header,
    .upload-progress-info {
        flex-wrap: wrap;
    }

    .result-header,
    .ai-result-header {
        align-items: flex-start;

        gap: 10px;

        flex-direction: column;
    }
}