/* ===== PHONG CÁCH EVN ===== */
:root {
    --primary-color: #00509E;
    /* Xanh dương EVN */
    --secondary-color: #3376BC;
    /* Cam thương hiệu EVN */
    --background-color: #FBF7F4;
    /* Xám nền rất nhạt */
    --container-bg: #C7D7FB;
    /* Trắng tinh */
    --text-color: #333333;
    /* Đen xám cho văn bản */
    --header-text-color: #FFFFFF;
    /* Trắng tinh cho chữ trên nền tối */
    --border-color: #DDE1E6;
    /* Xám nhạt cho viền */
    --status-green: #2E7D32;
    /* Xanh lá thành công */
    --status-yellow: #FFA000;
    /* Vàng cảnh báo */
    --status-red: #C62828;
    /* Đỏ nguy hiểm */
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@keyframes flash-red {
    0%,
    100% {
        background-color: #E57373;
        box-shadow: 0 0 4px rgba(220, 53, 69, 0.4);
    }
    50% {
        background-color: #EF5350;
        box-shadow: 0 0 12px rgba(220, 53, 69, 0.8);
    }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    font-weight: 500;
}

.main-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2vh 0;
}

/* --- Login --- */
.login-container {
    padding: 40px;
    background: #53A57D;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-weight: 850;
    
}

.login-container h2 {
    color: var(--text-color);
    margin-bottom: 24px;
    font-weight: 350;
    font-size: 1.5rem;
}

.login-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1rem;
}

.login-container button {
    width: 100%;
    padding: 14px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color: 0.2s;
    font-weight: 700;
}

.login-container button:hover {
    background-color: var(--secondary-color);
}

.error-message {
    color: var(--status-red);
    margin-top: 10px;
    font-weight: 600;
    display: none;
}

/* --- App Layout --- */
.app-container {
    width: 95%;
    max-width: 1300px;
    min-height: 95vh;
    background: var(--container-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: var(--header-text-color);
    flex-shrink: 0;
}

.header-title {
    line-height: 1.3;
}

.app-header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.header-subtitle {
    font-size: 0.9rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info span {
    font-weight: 600;
}

.user-info #user-role-display {
    background-color: rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.user-info button {
    background: var(--status-red);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

/* --- Tabs --- */
.tab-nav {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
    overflow-x: auto;
}

.tab-nav button {
    padding: 16px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    border-bottom: 4px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-nav button.active {
    color: var(--primary-color);
    border-bottom-color: var(--secondary-color);
}

.tab-content {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: #f7f9fc;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* --- Dashboard --- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

.dashboard-stats-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chart-container {
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
}

.stats-summary {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.stats-summary h3 {
    margin-top: 0;
    text-align: center;
    font-weight: 700;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    padding: 10px 0;
}

.stats-item .label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.stats-item .color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.stats-item .value {
    font-weight: 700;
    font-size: 1.3rem;
}

#dashboard .summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.summary-card {
    background: #edf5fc;
    padding: 20px;
    border-radius: 8px;
    border-left: 6px solid;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.summary-card h3 {
    margin-top: 0;
    font-weight: 700;
}

.summary-card p {
    margin: 4px 0;
}

.summary-card.status-green {
    border-color: var(--status-green);
}

.summary-card.status-yellow {
    border-color: var(--status-yellow);
}

.summary-card.status-red {
    border-left-color: transparent;
    color: white;
    animation: flash-red 2s infinite ease-in-out;
}

.summary-card.status-red .timestamp {
    color: rgba(255, 255, 255, 0.85);
}

.summary-card .timestamp {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 10px;
}

.summary-card .device-list {
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 600;
}

.dashboard-handover-reports {
    display: flex;
    gap: 24px;
    margin-top: 24px;
    align-items: flex-start;
}

.dashboard-handover-reports > .bdt-report-section {
    flex: 1;
    margin-top: 0;
}

#active-vessels-at-handover-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
#active-vessels-at-handover-list li {
    background-color: #f8f9fa;
    padding: 10px 15px;
    border-left: 4px solid var(--secondary-color);
    margin-bottom: 5px;
    border-radius: 4px;
    font-weight: 600;
}


/* --- Shift & Equipment --- */
.shift-control-panel {
    margin-bottom: 24px;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.shift-status-message {
    padding: 12px;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 6px;
    font-weight: 600;
    color: #856404;
    text-align: center;
}


.shift-control-panel h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-weight: 700;
}

.shift-control-panel .form-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.shift-control-panel button {
    padding: 10px 20px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.shift-control-panel button:hover {
    background-color: var(--secondary-color);
}

.handover-section {
    text-align: center;
    margin-top: 32px;
}

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.equipment-block {
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
    color: var(--text-color);
    background-color: #fff;
}

.equipment-block h3 {
    margin-top: 0;
    font-weight: 700;
}

.equipment-block.status-available {
    background-color: #C8E6C9;
    border-left: 10px solid var(--status-green);
}

.equipment-block.status-monitoring {
    background-color: #FFECB3;
    border-left: 10px solid var(--status-yellow);
}

.equipment-block.status-unavailable {
    border-left: 10px solid var(--status-red);
    color: white;
    animation: flash-red 5s infinite ease-in-out;
}

.status-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.status-buttons button {
    flex-grow: 1;
    padding: 10px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    background-color: #f8f9fa;
    color: #333;
}

.status-buttons button:hover {
    border-color: var(--primary-color);
}

.status-buttons button.active {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px var(--primary-color);
    border-color: var(--primary-color);
    background-color: var(--secondary-color);
    color: white;
}

.shift-inactive .status-buttons button {
    cursor: not-allowed;
    opacity: 0.6;
}

.shift-inactive .details-form {
    display: none !important;
}

.details-form {
    display: none;
    margin-top: 16px;
}

.details-form textarea {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    min-height: 60px;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.details-form button {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

.info-display {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px;
    border-radius: 6px;
    margin-top: 16px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    word-wrap: break-word;
}

.info-display strong {
    color: var(--primary-color);
    font-weight: 700;
}

.equipment-block.status-unavailable .info-display {
    background-color: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.equipment-block.status-unavailable .info-display strong {
    color: #ffdddd;
}

/* --- Bốc dỡ than Styles --- */
.bocdo-container .section-block {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}
.bocdo-container h3, .shift-control-panel h3 {
    margin-top: 0;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 16px;
}
.bocdo-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 24px;
}
.form-field { display: flex; flex-direction: column; }
.form-field label { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.form-field input, .form-field select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
    width: 100%;
}
.form-field-radio-group label { margin-bottom: 8px; }
.form-field-radio-group div { display: flex; gap: 15px; align-items: center; }

.bocdo-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 0.9rem; }
.bocdo-table th, .bocdo-table td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: left;
    vertical-align: middle;
}
.bocdo-table thead { background-color: #e9ecef; }
.bocdo-table th { font-weight: 700; }
.bocdo-table input[type="number"] { width: 80px; padding: 4px; border-radius: 4px; border: 1px solid #ccc; }
.bocdo-table .action-btn { font-size: 0.85rem; padding: 6px 12px; }
.bocdo-table .release-btn { background-color: var(--status-green); }

#bdt-summary-table thead tr:first-child th,
#bdt-pre-shift-summary-table thead tr:first-child th {
     background-color: #fffacd; /* Light Yellow */
     text-align: center;
}
#bdt-summary-table .sub-header th,
#bdt-pre-shift-summary-table .sub-header th {
    background-color: #f7f2d8;
    text-align: center;
}

.summary-table-top {
    background-color: #eef5fa;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    max-width: 580px;
    margin-right: auto;
    margin-left: 0;            
}
.summary-table-top table {
    border-collapse: separate;
    border-spacing: 0 2px;
    border: none;
    width: 100%;
}
.summary-table-top tr {
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    transition: transform 0.2s ease-in-out;
}
.summary-table-top tr:hover {
    transform: translateY(-2px);
}
.summary-table-top td {
    border: none;
    padding: 10px 16px;
}
.summary-table-top td:first-child {
    font-weight: 700;
    color: var(--primary-color);
    border-left: 5px solid var(--secondary-color);
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}
.summary-table-top td:last-child {
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
    text-align: right;
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

.bocdo-table .port-group-header td {
    font-weight: 700;
    font-size: 1.1rem;
    background-color: var(--secondary-color);
    color: white;
    padding: 12px;
}
 .bocdo-table .berth-group-header td {
    font-weight: 600;
    background-color: #d4e3f3;
    padding-left: 20px;
}
.bocdo-table .kho-cell { text-align: center; }

.bocdo-container fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-top: 10px;
}
.bocdo-container legend {
    font-weight: 700;
    padding: 0 8px;
    color: var(--primary-color);
}
#bdt-thiet-bi-wrapper { display: flex; flex-direction: column; }
#bdt-thiet-bi-checkboxes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 8px;
}
 #bdt-thiet-bi-checkboxes > div {
     display: flex;
     align-items: center;
 }
 #bdt-thiet-bi-checkboxes input { width: auto; margin-right: 8px; }

.bdt-report-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 32px;
}

/* --- Modal & Export --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 25, 47, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-top: 0;
    font-weight: 700;
    color: var(--primary-color);
}

.modal-handover-item {
    display: grid;
    grid-template-columns: 1fr 2fr;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.modal-handover-item:last-child {
    border-bottom: none;
}

.modal-handover-item .device-name {
    font-weight: 700;
}

.modal-handover-item .status-buttons button {
    padding: 8px;
    font-size: 0.9rem;
}

.modal-handover-item .details-form {
    margin-top: 10px;
}

.modal-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
}

.btn.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.btn.secondary-btn {
    background-color: #6c757d;
    color: white;
}

.hidden {
    display: none !important;
}

.export-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 32px;
}

.export-section h3 {
    margin-top: 0;
    font-weight: 700;
}

.export-controls {
    display: grid;
    gap: 16px;
    align-items: end;
    grid-template-columns: 1fr;
}

.export-controls>div {
    display: flex;
    flex-direction: column;
}

.export-controls label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.export-controls input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-sizing: border-box;
}

.export-controls button {
    width: 100%;
}

@media (min-width: 550px) {
    .export-controls {
        grid-template-columns: 1fr 1fr;
    }
    .export-controls button {
        grid-column: 1 / -1;
    }
}

@media (min-width: 850px) {
    .export-controls {
        grid-template-columns: 1fr 1fr auto;
    }
    .export-controls button {
        grid-column: auto;
        width: auto;
    }
}


@media (max-width: 768px) {
    .main-wrapper {
        align-items: flex-start;
        padding: 0;
    }
    .app-container {
        width: 100%;
        height: 100vh;
        min-height: 0;
        border-radius: 0;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }
    .app-header h1 {
        font-size: 1.3rem;
    }
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    .tab-nav button {
        padding: 12px 16px;
        font-size: 0.9rem;
        font-weight: 700;
    }
    .tab-content {
        padding: 16px;
    }
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .equipment-grid {
        grid-template-columns: 1fr;
    }
    .shift-control-panel .form-group {
        flex-direction: column;
        align-items: stretch;
    }
    .modal-content {
        padding: 24px;
    }
    .modal-handover-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    /* MODIFIED: Stack report boxes on small screens */
    .dashboard-handover-reports {
        flex-direction: column;
    }
}