/* File: css/style.css (Optimized for Readability, Performance, and Responsiveness) */

/* ===== 1. GLOBAL VARIABLES & RESET ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --brand-color: #A482ED;
    --brand-color-light: #f3effc;
    --background-color: #F7F8FC;
    --card-background: #FFFFFF;
    --text-dark: #2c3e50;
    --text-light: #9fa8b9;
    --border-color: #EFEFEF;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== 2. BASE STYLES ===== */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-dark);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-dark);
    margin-top: 0;
    margin-bottom: 0.5rem;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

a {
    text-decoration: none;
    color: var(--brand-color);
    transition: color 0.2s ease;
}

a:hover {
    text-decoration: underline;
    color: darken(var(--brand-color), 10%);
}

/* ===== 3. LAYOUT & CONTAINERS ===== */
.container.wide {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

main {
    padding: 2rem 1rem;
}

.content-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
}

/* ===== 4. HEADER & NAVIGATION ===== */
header {
    background-color: var(--card-background);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
    flex-wrap: wrap;
}

.logo-container {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 1rem 0;
}

.logo-container .logo {
    width: 40px;
    height: 40px;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-container .logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.main-nav {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-light);
    font-weight: 600;
    margin-left: 1rem;
    padding: 1rem 0.5rem;
    display: inline-block;
    border-bottom: 3px solid transparent;
    text-transform: uppercase;
    font-size: 0.85em;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.main-nav a.active,
.main-nav a:hover {
    color: var(--brand-color);
    border-bottom-color: var(--brand-color);
}

/* ===== 5. BUTTONS & FORMS ===== */
#get-ai-analysis-btn {
    background-color: var(--brand-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

#get-ai-analysis-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(164, 130, 237, 0.4);
}

.filter-container {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.filter-container form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.filter-item {
    flex: 1;
    min-width: 100%;
}

.filter-item label {
    display: block;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 8px;
}

.filter-item select,
.filter-item input {
    width: 100%;
    padding: 10px;
    border: 1px solid #D8D8D8;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.filter-item select:focus,
.filter-item input:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 5px rgba(164, 130, 237, 0.3);
}

.filter-item button {
    width: 100%;
    background-color: var(--brand-color);
    color: white;
    font-weight: 600;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    height: 41px;
    transition: transform 0.2s;
}

.filter-item button:hover {
    transform: scale(1.05);
}

.form-container.card-style {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.form-container.card-style form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 8px;
}

.form-group select,
.form-group input {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border: 1px solid #D8D8D8;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 5px rgba(164, 130, 237, 0.3);
}

.btn-upload {
    background-color: var(--brand-color);
    color: white;
    font-weight: 600;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-upload:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(164, 130, 237, 0.4);
}

/* ===== 6. SUMMARY CARDS & CHARTS ===== */
.title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.title-bar h2 {
    margin: 0;
    color: var(--text-dark);
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-basis: 100%;
    text-align: center;
    margin-bottom: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    background-color: var(--brand-color);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card.pie-card {
    background-color: var(--card-background);
    color: var(--text-dark);
    grid-column: span 1;
}

.summary-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.summary-card .card-header h4 {
    margin: 0;
    font-weight: 400;
    text-transform: uppercase;
    font-size: 0.85em;
    opacity: 0.9;
}

.summary-card.pie-card h4 {
    color: var(--text-dark);
    opacity: 1;
    text-align: center;
    width: 100%;
}

.summary-card p {
    font-size: 1.8em;
    font-weight: 700;
    margin: 0;
}

.summary-card input[type="checkbox"].metric-toggle {
    -webkit-appearance: none;
    appearance: none;
    background-color: rgba(255, 255, 255, 0.3);
    margin: 0;
    width: 1.5em;
    height: 1.5em;
    border-radius: 5px;
    cursor: pointer;
    display: grid;
    place-content: center;
}

.summary-card input[type="checkbox"].metric-toggle::before {
    content: "";
    width: 0.8em;
    height: 0.8em;
    background-color: white;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
}

.summary-card input[type="checkbox"].metric-toggle:checked::before {
    transform: scale(1);
}

.chart-container.full-width {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

/* ===== 7. TABLES ===== */
.table-container {
    background-color: var(--card-background);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
    table-layout: auto;
}

th,
td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

th {
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8em;
}

td {
    font-weight: 500;
}

tr:last-child td {
    border-bottom: none;
}

.table-container th:nth-child(2),
.table-container td:nth-child(2) {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Fix extra dots and spacing below DataTables pagination */
.dataTables_wrapper .dataTables_info {
    margin-top: 0.5em;
    font-size: 0.9em;
    padding-left: 0.5em;
}

.dataTables_wrapper .dataTables_paginate {
    margin-top: 0.5em;
    padding-right: 0.5em;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.3em 0.8em;
    margin-left: 0.3em;
    margin-right: 0.3em;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    color: #7a5af8;
    font-weight: 600;
    font-size: 0.9em;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background-color: #7a5af8;
    color: white !important;
    border: 1px solid #7a5af8;
    box-shadow: 0 0 5px rgba(122, 90, 248, 0.6);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background-color: #5a3ed8;
    color: white !important;
    border: 1px solid #5a3ed8;
    box-shadow: 0 0 8px rgba(90, 62, 216, 0.8);
}

/* ===== 8. ALERTS & AI RESULTS ===== */
.ai-result-box,
.alert {
    margin-bottom: 2rem;
    background-color: var(--brand-color-light);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--brand-color);
    padding: 1.5rem;
    border-radius: 8px;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    border-left-color: #155724;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    border-left-color: #721c24;
    color: #721c24;
}

.brand-table {
    align-self: start;
}

/* ===== 9. LOGIN PAGE STYLES ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--background-color);
    padding: 1rem;
}

.login-box {
    background-color: var(--card-background);
    padding: 2rem 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    text-align: center;
}

.login-box h3 {
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.login-box .alert {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95em;
}

.login-box .alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-left: 5px solid #721c24;
    color: #721c24;
    text-align: left;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-box .form-group {
    text-align: left;
}

.login-box .form-group label {
    display: block;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}

.login-box .form-group input[type="text"],
.login-box .form-group input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 1em;
    border: 1px solid #D8D8D8;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.login-box .form-group input[type="text"]:focus,
.login-box .form-group input[type="password"]:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 5px rgba(164, 130, 237, 0.5);
}

.login-box .btn-upload {
    background-color: var(--brand-color);
    color: white;
    font-weight: 600;
    padding: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.login-box .btn-upload:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(164, 130, 237, 0.4);
}

/* ===== 10. RESPONSIVE DESIGN ===== */

/* Mobile First: Base styles are mobile-first */

/* Small devices (phones, 480px and up) */
@media (min-width: 480px) {
    .login-box {
        padding: 2rem 2.5rem;
        max-width: 400px;
    }

    .logo-container .logo {
        font-size: 1.5rem;
    }

    .logo-container span {
        font-size: 1.2rem;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    header {
        padding: 0 2rem;
    }

    .main-nav a {
        margin-left: 2rem;
        padding: 2rem 0.5rem;
        font-size: 0.9em;
    }

    main {
        padding: 2rem;
    }

    .container.wide {
        padding: 0 2rem;
    }

    .title-bar h2 {
        font-size: 1.5rem;
        letter-spacing: 1.5px;
        flex-basis: auto;
        text-align: left;
        margin-bottom: 0;
    }

    .filter-container form {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 2rem;
    }

    .filter-item {
        min-width: 200px;
    }

    .form-row {
        flex-direction: row;
        gap: 2rem;
    }

    .summary-card p {
        font-size: 2em;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .content-grid {
        grid-template-columns: 1fr 2fr;
    }
}

/* Extra large devices (large desktops, 1400px and up) */
@media (min-width: 1400px) {
    .summary-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .summary-card.pie-card {
        grid-column: span 2;
    }
}

/* ===== 11. UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none;
}

.visible {
    display: block;
}

/* ===== 12. ANIMATIONS & TRANSITIONS ===== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

/* Style untuk Run Rate */
.run-rate-container {
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.progress-item {
    display: flex;
    flex-direction: column;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.progress-label span:last-child {
    color: var(--brand-color);
}

progress {
    width: 100%;
    height: 10px;
    border-radius: 5px;
}

progress::-webkit-progress-bar {
    background-color: #eee;
    border-radius: 5px;
}

progress::-webkit-progress-value {
    background-color: var(--brand-color);
    border-radius: 5px;
}

.progress-detail {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-light);
    margin-top: 0.5rem;
}