/* ====================================
   SISTEM MANAJEMEN SURAT - MODERN UI
   ==================================== */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #1e293b;
    --light: #f1f5f9;
    --sidebar-width: 280px;
    --topbar-height: 70px;
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    overflow-x: hidden;
}

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

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

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

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

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

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-brand {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    background: rgba(99, 102, 241, 0.1);
}

.sidebar-brand i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.75rem;
    display: block;
}

.sidebar-brand h5 {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
    letter-spacing: -0.5px;
}

.sidebar-brand small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-weight: 500;
    display: block;
    margin-top: 0.25rem;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-title {
    padding: 1rem 1.5rem 0.5rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
    margin: 0.25rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary);
    transform: scaleY(0);
    transition: var(--transition);
}

.menu-item:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
    transform: translateX(5px);
}

.menu-item:hover::before {
    transform: scaleY(1);
}

.menu-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(129, 140, 248, 0.2) 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.menu-item.active::before {
    transform: scaleY(1);
}

.menu-item i {
    width: 24px;
    text-align: center;
    margin-right: 1rem;
    font-size: 1.1rem;
}

.menu-item span {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

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

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
    background: var(--light);
}

/* ====================================
   TOP NAVBAR
   ==================================== */

.top-navbar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--dark);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Marquee Greeting */
.marquee-container {
    flex: 1;
    max-width: 600px;
    overflow: hidden;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.marquee-content {
    display: flex;
    align-items: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    animation: marquee 20s linear infinite;
}

.marquee-content i {
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

@keyframes marquee {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* Clock & Date */
.datetime-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: white;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.clock-box, .date-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clock-box i, .date-box i {
    color: var(--primary);
    font-size: 1.1rem;
}

#clockDisplay {
    font-weight: 700;
    font-size: 1rem;
    color: var(--dark);
    font-variant-numeric: tabular-nums;
}

#dateDisplay {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--secondary);
}

/* Topbar Right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notification-btn {
    position: relative;
    background: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.notification-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.notification-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid white;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-profile:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.user-info h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dark);
}

.user-info small {
    font-size: 0.75rem;
    color: var(--secondary);
    font-weight: 500;
}

.user-profile i.fa-chevron-down {
    color: var(--secondary);
    font-size: 0.8rem;
}

/* ====================================
   CONTENT AREA
   ==================================== */

.content-wrapper {
    padding: 2rem;
    min-height: calc(100vh - var(--topbar-height) - 100px);
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header h1 i {
    color: var(--primary);
}

/* ====================================
   CARDS
   ==================================== */

.card {
    background: white;
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

.card-header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--dark);
}

.card-body {
    padding: 1.5rem;
}

/* Stats Cards */
.stats-card {
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: currentColor;
}

.stats-card.primary::before {
    background: var(--primary);
}

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

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

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

.stats-card .card-body {
    padding: 1.75rem;
}

.stats-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
    margin: 0;
}

.stats-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stats-icon {
    font-size: 3rem;
    opacity: 0.15;
}

/* ====================================
   BUTTONS
   ==================================== */

.btn {
    padding: 0.625rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.btn-success {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
}

.btn-warning {
    background: var(--warning);
}

.btn-info {
    background: var(--info);
}

/* ====================================
   BADGES
   ==================================== */

.badge {
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
}

/* ====================================
   TABLES
   ==================================== */

.table {
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    color: var(--secondary);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
}

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

.table tbody tr:hover {
    background: #f8fafc;
    transform: scale(1.005);
}

.table tbody td {
    padding: 1rem 0.75rem;
    vertical-align: middle;
}

/* ====================================
   FORMS
   ==================================== */

.form-label {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-control, .form-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.675rem 1rem;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ====================================
   ALERTS
   ==================================== */

.alert {
    border: none;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
}

/* ====================================
   FOOTER
   ==================================== */

.footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    margin-top: auto;
}

/* ====================================
   RESPONSIVE - PERBAIKAN FINAL
   ==================================== */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    /* HIDE marquee & datetime di tablet */
    .marquee-container {
        display: none !important;
    }
    
    .datetime-display {
        display: none !important;
    }
    
    /* Topbar adjustment - lebih simple */
    .top-navbar {
        padding: 0 1rem;
        height: 60px;
    }
    
    .topbar-left {
        width: auto;
    }
    
    .topbar-right {
        margin-left: auto;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    /* Topbar lebih compact */
    .top-navbar {
        height: 56px;
        padding: 0.5rem 1rem;
    }
    
    /* PASTIKAN marquee & datetime HIDDEN */
    .marquee-container,
    .datetime-display {
        display: none !important;
    }
    
    /* User info hide di mobile */
    .user-info {
        display: none;
    }
    
    .user-profile {
        padding: 0.5rem;
        gap: 0;
    }
    
    .user-profile i.fa-chevron-down {
        display: none;
    }
    
    /* Notification button smaller */
    .notification-btn {
        width: 40px;
        height: 40px;
    }
    
    .notification-btn i {
        font-size: 1.1rem;
    }
    
    /* Content adjustment */
    .content-wrapper {
        padding: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    /* Stats card mobile */
    .stats-card .card-body {
        padding: 1.25rem;
    }
    
    .stats-value {
        font-size: 1.75rem;
    }
    
    .stats-label {
        font-size: 0.75rem;
    }
    
    .stats-icon {
        font-size: 2.5rem;
    }
    
    /* Table responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
    }
}

@media (max-width: 576px) {
    /* Extra small devices */
    .top-navbar {
        height: 52px;
        padding: 0.5rem 0.75rem;
    }
    
    .notification-btn {
        width: 36px;
        height: 36px;
    }
    
    .notification-btn i {
        font-size: 1rem;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    /* Card padding mobile */
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem 1.25rem;
        font-size: 0.9rem;
    }
    
    /* Button mobile */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Form mobile */
    .form-control,
    .form-select {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    .form-label {
        font-size: 0.85rem;
    }
    
    /* Stats cards 1 column */
    .col-xl-3.col-md-6 {
        margin-bottom: 1rem;
    }
}

/* ====================================
   TOPBAR LAYOUT FIX
   ==================================== */

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Show only at desktop */
@media (min-width: 993px) {
    .mobile-toggle {
        display: none;
    }
    
    .marquee-container {
        display: block;
    }
    
    .datetime-display {
        display: flex;
    }
}

/* ====================================
   RESPONSIVE
   ==================================== */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .marquee-container {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
    }
    
    .datetime-display {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }
    
    .user-info {
        display: none;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
}

/* ====================================
   RESPONSIVE - PERBAIKAN
   ==================================== */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Overlay saat sidebar terbuka */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: block;
    }
    
    /* Hide marquee di tablet */
    .marquee-container {
        display: none;
    }
    
    /* Topbar adjustment */
    .top-navbar {
        padding: 0 1rem;
    }
    
    .datetime-display {
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --topbar-height: auto;
    }
    
    /* Topbar Mobile */
    .top-navbar {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        height: auto;
    }
    
    .topbar-left {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 0.75rem;
    }
    
    .topbar-right {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* Hide marquee di mobile */
    .marquee-container {
        display: none;
    }
    
    /* DateTime display untuk mobile - 2 baris */
    .datetime-display {
        flex-direction: column;
        gap: 0.25rem;
        padding: 0.5rem 0.75rem;
        width: 100%;
        order: 3;
    }
    
    .clock-box, .date-box {
        justify-content: center;
        width: 100%;
    }
    
    #clockDisplay {
        font-size: 0.95rem;
    }
    
    #dateDisplay {
        font-size: 0.8rem;
    }
    
    /* User info hide di mobile */
    .user-info {
        display: none;
    }
    
    .user-profile {
        padding: 0.5rem;
    }
    
    /* Content adjustment */
    .content-wrapper {
        padding: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    /* Stats card mobile */
    .stats-value {
        font-size: 1.5rem;
    }
    
    .stats-icon {
        font-size: 2rem;
    }
    
    /* Table responsive */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 576px) {
    /* Extra small devices */
    .datetime-display {
        font-size: 0.85rem;
    }
    
    .notification-btn {
        width: 38px;
        height: 38px;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    /* Card padding mobile */
    .card-body {
        padding: 1rem;
    }
    
    /* Button mobile */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

/* ====================================
   SIDEBAR OVERLAY (untuk close sidebar)
   ==================================== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Sidebar close button untuk mobile */
.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

@media (max-width: 992px) {
    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ====================================
   ANIMATIONS
   ==================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ====================================
   UTILITIES
   ==================================== */

.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.shadow-sm {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.shadow-lg {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}