/* ======================================
   PMedia Nội Bộ - Design System CSS
   Colors derived from PMedia logo (Teal)
   ====================================== */

@import url('https://fonts.googleapis.com/css2?family=Google+Sans:ital,opsz,wght@0,17..18,400..700;1,17..18,400..700&display=swap');

:root {
    /* Brand Colors from Logo */
    --primary: #17736E;
    --primary-dark: #0D4A47;
    --primary-light: #2AA5A0;
    --primary-bg: #F0F9F8;
    --secondary: #2AA5A0;
    --accent: #E8A838;
    --accent-light: #FFF3E0;

    /* Semantic Colors */
    --success: #10B981;
    --success-bg: #ECFDF5;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --info: #3B82F6;
    --info-bg: #EFF6FF;

    /* Neutral Colors */
    --text-primary: #0D4A47;
    --text-secondary: #4B6563;
    --text-muted: #6B8280;
    --bg-body: #F0F9F8;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0D4A47;
    --border-color: #D1E5E3;
    --border-light: #E8F4F2;

    /* Typography */
    --font-heading: "Google Sans", sans-serif;
    --font-body: "Google Sans", sans-serif;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(13, 74, 71, 0.08);
    --shadow-md: 0 4px 12px rgba(13, 74, 71, 0.1);
    --shadow-lg: 0 8px 24px rgba(13, 74, 71, 0.12);
    --shadow-hover: 0 6px 20px rgba(23, 115, 110, 0.15);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition: all 0.2s ease;
}

/* ====== Base ====== */
html {
    font-size: 14px;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
}

/* ====== Sidebar ====== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0A3835 100%);
    z-index: 1002;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Minimized state (desktop) */
.sidebar.minimized {
    width: 64px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 66px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-brand-text-wrap {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.25s ease;
    width: auto;
}

.sidebar.minimized .sidebar-brand-text-wrap {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.sidebar-brand-text {
    color: white;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

.sidebar-brand-sub {
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 400;
}

/* Minimize button */
.sidebar-minimize-btn {
    position: absolute;
    top: 18px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--secondary);
    border: 2px solid #0D4A47;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1003;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.sidebar-minimize-btn:hover {
    background: var(--primary-light);
    transform: scale(1.1);
}

/* Hide minimize btn on mobile */
@media (max-width: 991px) {
    .sidebar-minimize-btn {
        display: none;
    }
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.sidebar.minimized .sidebar-section {
    opacity: 0;
    pointer-events: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    transition: var(--transition);
    border-left: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.sidebar-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--secondary);
}

.sidebar-link.active {
    color: white;
    background: rgba(42, 165, 160, 0.15);
    border-left-color: var(--secondary);
    font-weight: 500;
}

.sidebar-link i,
.sidebar-link svg {
    width: 20px;
    min-width: 20px;
    height: 20px;
    opacity: 0.75;
    font-size: 1.05rem;
    transition: var(--transition);
}

.sidebar-link.active i,
.sidebar-link.active svg {
    opacity: 1;
    color: var(--secondary);
}

.sidebar-link-text {
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.sidebar.minimized .sidebar-link-text {
    opacity: 0;
    pointer-events: none;
}

/* Tooltip on minimized */
.sidebar.minimized .sidebar-link {
    padding-left: 60px;
    justify-content: center;
}

.sidebar.minimized .sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    background: var(--primary-dark);
    color: white;
    font-size: 0.8rem;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 2000;
    box-shadow: var(--shadow-md);
}

.sidebar.minimized .sidebar-link:hover::after {
    opacity: 1;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar.minimized .sidebar-footer {
    padding: 12px 8px;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ====== Main Content ====== */
.main-content {
    margin-left: 200px;
    min-height: 100vh;
    padding: 0;
    transition: margin-left 0.25s ease;
}

.sidebar.minimized~.main-content,
.main-content.minimized {
    margin-left: 64px;
}

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
    min-height: 54px;
}

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

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

.topbar-hamburger {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.topbar-hamburger:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.topbar-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
}

.topbar-date {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.page-content {
    padding: 24px 28px;
}

/* ====== KPI Cards ====== */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.kpi-card.kpi-warning::before {
    background: var(--warning);
}

.kpi-card.kpi-danger::before {
    background: var(--danger);
}

.kpi-card.kpi-success::before {
    background: var(--success);
}

.kpi-card.kpi-info::before {
    background: var(--info);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.kpi-icon.bg-primary {
    background: rgba(23, 115, 110, 0.12);
    color: var(--primary);
}

.kpi-icon.bg-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.kpi-icon.bg-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.kpi-icon.bg-success {
    background: var(--success-bg);
    color: var(--success);
}

.kpi-icon.bg-info {
    background: var(--info-bg);
    color: var(--info);
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ====== Data Table ====== */
.data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.data-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(23, 115, 110, 0.03);
}

.data-card-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: var(--primary-bg);
    border-bottom: 2px solid var(--border-color);
    padding: 10px 12px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(23, 115, 110, 0.04);
}

.data-table tbody td {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody td:first-child {
    font-weight: 500;
    color: var(--text-primary);
}

/* Editable cell */
.editable-cell {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    min-height: 28px;
}

.editable-cell:hover {
    background: var(--primary-bg);
}

.editable-cell input,
.editable-cell select,
.editable-cell textarea {
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.85rem;
    font-family: var(--font-body);
    width: 100%;
    outline: none;
    transition: var(--transition);
}

.editable-cell input:focus,
.editable-cell select:focus,
.editable-cell textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 115, 110, 0.15);
}

/* ====== Status Badges ====== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: #92400E;
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-primary {
    background: rgba(23, 115, 110, 0.1);
    color: var(--primary);
}

/* ====== Checklist ====== */
.checklist-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
}

.checklist-section-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(23, 115, 110, 0.03);
    cursor: pointer;
}

.checklist-section-header:hover {
    background: rgba(23, 115, 110, 0.06);
}

.checklist-section-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.checklist-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.checklist-progress-bar {
    width: 100px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.checklist-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.checklist-progress-fill.complete {
    background: var(--success);
}

.checklist-items {
    padding: 8px 0;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 20px;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-light);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item:hover {
    background: rgba(23, 115, 110, 0.03);
}

.checklist-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.checklist-item-text {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checklist-item-text.checked {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.7;
}

.checklist-item-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-style: italic;
}

/* ====== Tabs ====== */
.tracker-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.tracker-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.tracker-tab:hover {
    color: var(--text-primary);
    background: var(--primary-bg);
}

.tracker-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* ====== Buttons ====== */
.btn-pm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-pm-primary {
    background: var(--primary);
    color: white;
}

.btn-pm-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-pm-accent {
    background: var(--accent);
    color: white;
}

.btn-pm-accent:hover {
    background: #D4952E;
}

.btn-pm-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-pm-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-pm-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-pm-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-pm-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

/* ====== Modal ====== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    background: var(--primary-bg);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
}

/* ====== Forms ====== */
.form-label-pm {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.form-control-pm {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control-pm:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 115, 110, 0.12);
    outline: none;
}

/* ====== Empty State ====== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 12px;
}

.empty-state-text {
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* ====== Responsive ====== */

/* Tablet and below: sidebar off-screen by default, slides in on .mobile-open */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 200px !important;
        /* always full on mobile */
        z-index: 1002;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .topbar {
        padding: 10px 16px;
    }

    .page-content {
        padding: 16px;
    }
}

/* Small phones */
@media (max-width: 575px) {
    .tracker-tabs {
        flex-wrap: wrap;
        gap: 3px;
    }

    .tracker-tab {
        flex: 1 1 46%;
        font-size: 0.73rem;
        padding: 8px 8px;
    }

    .kpi-value {
        font-size: 1.3rem;
    }

    .kpi-card {
        padding: 14px;
    }

    .page-content {
        padding: 12px;
    }

    .topbar-title {
        font-size: 0.9rem;
    }

    .data-table thead th,
    .data-table tbody td {
        padding: 7px 8px;
        font-size: 0.8rem;
    }

    .modal-dialog {
        margin: 8px;
    }
}

/* ====== Animations ====== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

/* ====== Scrollbar ====== */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ====== Utility ====== */
.text-primary-pm {
    color: var(--primary) !important;
}

.text-danger-pm {
    color: var(--danger) !important;
}

.text-warning-pm {
    color: var(--warning) !important;
}

.text-success-pm {
    color: var(--success) !important;
}

.bg-primary-pm {
    background-color: var(--primary) !important;
}

.currency {
    font-family: var(--font-heading);
}

.nowrap {
    white-space: nowrap;
}

.nested-column .last-no-border:last-child {
    border-bottom: none !important;
}