/* ============================================
   MA AT-TAQWA YASTU - Modern Admin Theme
   Version: 2.0
   ============================================ */

/* === CSS Variables === */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 60px;
    
    /* Primary Colors - Islamic Green */
    --primary: #1a6b3c;
    --primary-light: #238a4e;
    --primary-dark: #0f4a28;
    --primary-50: #e8f5ec;
    --primary-100: #c5e8d0;
    --primary-200: #9fd9b3;
    
    /* Sidebar */
    --sidebar-bg: #0f1923;
    --sidebar-bg-hover: #1a2a38;
    --sidebar-text: #8b9eb0;
    --sidebar-text-active: #ffffff;
    --sidebar-border: #1e3040;
    
    /* Content */
    --content-bg: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    
    /* Transitions */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Login Page === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1923 0%, #1a2a38 50%, #0f4a28 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 70%, rgba(26, 107, 60, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 30%, rgba(35, 138, 78, 0.1) 0%, transparent 50%);
    animation: loginBg 20s ease-in-out infinite;
}

@keyframes loginBg {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(2%, -2%) rotate(1deg); }
    66% { transform: translate(-1%, 1%) rotate(-0.5deg); }
}

.login-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 48px 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-100);
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
}

.login-logo p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 20px;
    position: relative;
}

.login-form .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-form .form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: #fafbfc;
    transition: var(--transition);
    outline: none;
}

.login-form .form-group input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px var(--primary-50);
}

.login-form .form-group input::placeholder {
    color: var(--text-muted);
}

.login-form .btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.login-form .btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(26, 107, 60, 0.3);
}

.login-form .btn-login:active {
    transform: translateY(0);
}

.login-form .btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.login-links {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-links a {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.login-links a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

/* === Layout === */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--topbar-height);
    flex-shrink: 0;
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-brand-text {
    overflow: hidden;
}

.sidebar-brand-text h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--sidebar-text-active);
    white-space: nowrap;
    line-height: 1.3;
}

.sidebar-brand-text span {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand-text {
    display: none;
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 4px;
}

.nav-section {
    padding: 8px 16px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #4a5568;
}

.sidebar.collapsed .nav-section {
    display: none;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-bg-hover);
}

.nav-link.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-bg-hover);
    border-left-color: var(--primary-light);
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.nav-link .badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar.collapsed .nav-link span:not(.badge),
.sidebar.collapsed .nav-link .arrow {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .nav-link .badge {
    display: none;
}

/* Submenu */
.nav-submenu {
    display: none;
    background: rgba(0, 0, 0, 0.15);
}

.nav-submenu.open {
    display: block;
}

.nav-submenu .nav-link {
    padding-left: 52px;
    font-size: 0.825rem;
}

.nav-submenu .nav-link i {
    font-size: 0.7rem;
    width: auto;
}

.sidebar.collapsed .nav-submenu {
    display: none !important;
}

.nav-link .arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: var(--transition);
}

.nav-link.expanded .arrow {
    transform: rotate(90deg);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-info .name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sidebar-text-active);
    white-space: nowrap;
}

.sidebar-user-info .role {
    font-size: 0.7rem;
    color: var(--sidebar-text);
}

.sidebar.collapsed .sidebar-user-info {
    display: none;
}

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* === Topbar === */
.topbar {
    background: var(--card-bg);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

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

.topbar-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 1.1rem;
}

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

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user:hover {
    background: var(--content-bg);
}

.topbar-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.topbar-user .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-user .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* === Page Content === */
.page-content {
    flex: 1;
    padding: 24px;
}

/* === Cards === */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px 0;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* === Stats Cards === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

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

.stat-card.primary::before { background: var(--primary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.info::before { background: var(--info); }
.stat-card.danger::before { background: var(--danger); }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.stat-card.primary .stat-icon { background: var(--primary-50); color: var(--primary); }
.stat-card.success .stat-icon { background: #d1fae5; color: var(--success); }
.stat-card.warning .stat-icon { background: #fef3c7; color: var(--warning); }
.stat-card.info .stat-icon { background: #dbeafe; color: var(--info); }
.stat-card.danger .stat-icon { background: #fee2e2; color: var(--danger); }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card .stat-change {
    font-size: 0.8rem;
    margin-top: 8px;
    font-weight: 500;
}

.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* === Tables === */
.table-container {
    overflow-x: auto;
}

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

.data-table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: #f8f9fb;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8f9fb;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(26, 107, 60, 0.3);
}

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

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

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

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

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* === Forms === */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: #fff;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-50);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* === Alerts === */
.alert {
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-primary { background: var(--primary-50); color: var(--primary); }

/* === DataTables Overrides === */
.dataTables_wrapper .dataTables_filter input {
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.dataTables_wrapper .dataTables_length select {
    padding: 8px 32px 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px !important;
    border-radius: 8px !important;
    margin: 0 2px !important;
    border: none !important;
    font-size: 0.85rem !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-50) !important;
    color: var(--primary) !important;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .topbar-user .name,
    .topbar-user .role {
        display: none;
    }
}

/* === Overlay for mobile === */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* === Print === */
@media print {
    .sidebar, .topbar { display: none !important; }
    .main-content { margin-left: 0 !important; }
}
