/* ==========================================================================
   Monogruen Invoice Classification Tool — Monitoring UI
   Corporate Design: Clean, minimal, green accent (#2d6a4f / #40916c)
   ========================================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --green-900: #1b4332;
    --green-700: #2d6a4f;
    --green-600: #40916c;
    --green-400: #52b788;
    --green-200: #b7e4c7;
    --green-100: #d8f3dc;
    --green-50:  #f0faf4;

    --gray-900: #212529;
    --gray-700: #495057;
    --gray-500: #adb5bd;
    --gray-300: #dee2e6;
    --gray-100: #f8f9fa;
    --white:    #ffffff;

    --red-600:    #dc3545;
    --red-100:    #fde8ea;
    --yellow-600: #e5a100;
    --yellow-100: #fff8e1;

    --font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;

    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

html {
    font-size: 15px;
    line-height: 1.6;
}

body {
    font-family: var(--font-family);
    color: var(--gray-900);
    background-color: var(--gray-100);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
header {
    background: var(--green-900);
    color: var(--white);
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-logout {
    color: var(--green-200);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    border-color: rgba(255,255,255,0.4);
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-green {
    color: var(--green-400);
}

.logo-divider {
    color: var(--green-600);
    font-weight: 300;
    margin: 0 0.25rem;
}

.logo-subtitle {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--green-200);
}

/* ---------- Layout ---------- */
.layout-3col {
    display: grid;
    grid-template-columns: 320px 1fr 340px;
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    flex: 1;
    align-items: start;
}

.col-upload, .col-main, .col-output {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

h2 {
    font-size: 1.1rem;
    color: var(--green-900);
    border-bottom: 2px solid var(--green-200);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

/* ---------- Upload Zone ---------- */
.drop-zone {
    border: 2px dashed var(--green-400);
    border-radius: var(--radius);
    background: var(--white);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.drop-zone:hover, .drop-zone.dragover {
    background: var(--green-50);
    border-color: var(--green-700);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.drop-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.drop-zone p {
    font-weight: 600;
    color: var(--green-900);
}

.drop-subtitle {
    font-weight: 400 !important;
    font-size: 0.85rem;
    color: var(--gray-500) !important;
    margin-top: 0.25rem;
}

.drop-zone input[type="file"] {
    display: none;
}

.upload-status {
    font-size: 0.85rem;
    min-height: 20px;
    text-align: center;
}

.upload-info {
    font-size: 0.8rem;
    color: var(--gray-700);
    background: var(--white);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
    line-height: 1.4;
}

/* ---------- Filter Tabs ---------- */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--gray-700);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.tab:hover {
    background: var(--green-50);
    border-color: var(--green-400);
    color: var(--green-700);
}

.tab.active {
    background: var(--green-700);
    border-color: var(--green-700);
    color: var(--white);
}

.tab.active .badge {
    background: rgba(255,255,255,0.25);
    color: var(--white);
}

.badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    background: var(--gray-300);
    color: var(--gray-700);
    font-weight: 600;
}

.badge-success { background: var(--green-200); color: var(--green-900); }
.badge-error   { background: var(--red-100);   color: var(--red-600);   }
.badge-warning { background: var(--yellow-100); color: var(--yellow-600);}

/* ---------- Table ---------- */
.table-wrapper {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-300);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    background: var(--green-50);
    border-bottom: 2px solid var(--green-200);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--green-900);
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--gray-300);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--green-50);
}

/* ---------- Month Group Headers ---------- */
tr.month-header td {
    background: var(--green-100);
    padding: 0.6rem 1rem;
    border-bottom: 2px solid var(--green-400);
    border-top: 1px solid var(--green-200);
}

.month-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--green-900);
}

.month-count {
    font-size: 0.78rem;
    color: var(--green-600);
    margin-left: 0.75rem;
    font-weight: 500;
}

.status-cell {
    text-align: center;
    font-size: 1.1rem;
}

.amount {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    text-align: right;
    white-space: nowrap;
}

.filename {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--gray-700);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Row status highlights */
tr.status-error td {
    background: var(--red-100);
}

tr.status-manual_review_required td {
    background: var(--yellow-100);
}

/* Error detail row */
tr.error-detail td {
    padding: 0;
    background: var(--red-100);
}

tr.error-detail details {
    padding: 0.5rem 1rem;
}

tr.error-detail summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--red-600);
    font-weight: 500;
}

tr.error-detail pre {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--white);
    padding: 0.5rem;
    border-radius: var(--radius);
    margin-top: 0.5rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--gray-700);
}

/* ---------- Tags ---------- */
.tag {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tag-dir {
    background: var(--green-100);
    color: var(--green-700);
}

.tag-hospitality {
    background: #fff3cd;
    color: #856404;
    margin-left: 0.3rem;
}

/* ---------- Download Button ---------- */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: var(--green-600);
    color: var(--white);
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    transition: background 0.15s ease;
}

.btn-download:hover {
    background: var(--green-700);
}

.btn-download-pdf {
    background: var(--green-900);
}

.btn-download-pdf:hover {
    background: var(--green-700);
}

.downloads {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    white-space: nowrap;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-500);
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.empty-state a {
    color: var(--green-600);
    text-decoration: underline;
}

/* ---------- Output Folder Structure ---------- */
.tree-container {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--gray-300);
    box-shadow: var(--shadow-sm);
    min-height: 200px;
}

ul.tree, ul.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.tree ul {
    margin-left: 1rem;
    border-left: 1px solid var(--gray-300);
}

ul.tree li {
    margin: 0;
    padding: 0;
}

.folder {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--green-900);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    transition: background 0.15s;
    user-select: none;
}

.folder:hover {
    background: var(--green-50);
}

.file, .empty-dir {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--gray-700);
    padding: 0.25rem 0.5rem 0.25rem 1.5rem;
    position: relative;
}

.file::before, .empty-dir::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 0;
    width: 10px;
    height: 1px;
    background: var(--gray-300);
}

.empty-dir {
    color: var(--gray-500);
}

.folder-icon, .file-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
}

details > summary {
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

/* ---------- Footer ---------- */
footer {
    text-align: center;
    padding: 1.5rem 2rem;
    font-size: 0.75rem;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-300);
    margin-top: auto;
    background: var(--white);
}

/* ---------- Login Page ---------- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 3rem 1rem;
}

.login-card {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
}

.login-card h2 {
    border-bottom: none;
    margin-bottom: 0.25rem;
    text-align: center;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--gray-700);
    margin-bottom: 1.5rem;
}

.login-error {
    background: var(--red-100);
    color: var(--red-600);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.form-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--green-900);
    margin-bottom: 0.35rem;
}

.form-group input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: var(--font-family);
    transition: border-color 0.15s;
}

.form-group input[type="password"]:focus {
    outline: none;
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}

.btn-login {
    width: 100%;
    padding: 0.65rem 1rem;
    background: var(--green-700);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-family);
}

.btn-login:hover {
    background: var(--green-900);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .layout-3col {
        grid-template-columns: 1fr;
    }

    header {
        padding: 0 1rem;
    }

    .filter-tabs {
        gap: 0.3rem;
    }

    .tab {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.5rem 0.6rem;
    }
}
