/**
 * CIRED Malaysia - Main Stylesheet
 * Custom styles for the CIRED Malaysia application
 */

/* ========================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ======================================== */
:root {
    --primary-color: #1a365d;
    --secondary-color: #2b77ad;
    --accent-color: #4299e1;
    --success-color: #38a169;
    --warning-color: #d69e2e;
    --danger-color: #e53e3e;
    --gradient-primary: linear-gradient(135deg, #1a365d 0%, #2b77ad 100%);
    --gradient-light: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --navbar-height: 82px;
}

/* ========================================
   GLOBAL RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #2d3748;
    overflow-x: hidden;
    padding-top: var(--navbar-height);
}

/* ========================================
   NAVIGATION BAR STYLES
   ======================================== */
.navbar {
    background: var(--gradient-primary) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: var(--shadow-lg);
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.navbar.scrolled {
    padding: 0.5rem 0;
    background: rgba(26, 54, 93, 0.95) !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: white !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s ease;
}

.navbar-brand:hover {
    transform: scale(1.05);
}

/* Navigation Links */
.nav-link {
    color: rgba(255,255,255,0.9) !important;
    font-weight: 500;
    margin: 0 5px;
    padding: 8px 16px !important;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link:hover {
    color: white !important;
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}

.nav-link.active {
    background: rgba(255,255,255,0.2);
    color: white !important;
}

/* ========================================
   DROPDOWN MENU STYLES
   ======================================== */
.dropdown-menu {
    background: white;
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-top: 8px;
    min-width: 280px;
}

.dropdown-header {
    background: var(--gradient-light);
    padding: 12px 20px;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-item {
    padding: 12px 20px;
    transition: all 0.3s ease;
    border-bottom: 1px solid #f7fafc;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #4a5568;
}

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

.dropdown-item:hover {
    background: var(--gradient-light);
    transform: translateX(5px);
    color: #2d3748;
}

.dropdown-item i {
    width: 20px;
    font-size: 1.1rem;
    color: #6b7280;
}

.dropdown-item:hover i {
    color: var(--primary-color);
}

.dropdown-item.text-danger {
    color: #e53e3e;
}

.dropdown-item.text-danger:hover {
    background: #fff5f5;
    color: #c53030;
}

.dropdown-item.text-danger i {
    color: #e53e3e;
}

.dropdown-divider {
    margin: 0;
    border-color: #e2e8f0;
}

/* ========================================
   PROFILE AVATAR STYLES
   ======================================== */
.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.profile-initial {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Status Badge */
.status-badge {
    background: var(--success-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { 
        box-shadow: 0 0 5px var(--success-color); 
    }
    to { 
        box-shadow: 0 0 15px var(--success-color); 
    }
}

/* ========================================
   TOAST NOTIFICATION STYLES
   ======================================== */
.toast-container {
    max-width: 400px;
}

.toast {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: none;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast .toast-body {
    font-weight: 500;
    display: flex;
    align-items: center;
}

.toast .toast-body i {
    font-size: 1.1rem;
}

/* ========================================
   ALERT STYLES (DEPRECATED - USE TOASTS)
   ======================================== */
.alert {
    border: none;
    border-radius: var(--border-radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

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

.alert-success {
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    color: #22543d;
}

.alert-success::before {
    background: var(--success-color);
}

.alert-danger {
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    color: #742a2a;
}

.alert-danger::before {
    background: var(--danger-color);
}

/* ========================================
   MAIN CONTENT STYLES
   ======================================== */
main {
    min-height: calc(100vh - 200px);
    background: var(--gradient-light);
}

/* ========================================
   FOOTER STYLES
   ======================================== */
footer {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: white;
    padding: 60px 0 30px;
    position: relative;
    overflow: hidden;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-color), var(--secondary-color), var(--accent-color));
}

.footer-section h5 {
    color: white;
    font-weight: 600;
    margin-bottom: 20px;
    position: relative;
}

.footer-section h5::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--accent-color);
}

.footer-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-block;
    padding: 5px 0;
}

.footer-link:hover {
    color: var(--accent-color);
    transform: translateX(5px);
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 40px;
    padding-top: 20px;
    text-align: center;
    color: rgba(255,255,255,0.6);
}

/* ========================================
   CUSTOM SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ========================================
   LAYOUT CONSISTENCY — page top spacing
   ======================================== */

/* Page-hero section: visually extends behind the navbar */
.page-hero {
    margin-top: calc(-1 * var(--navbar-height));
    padding-top: var(--navbar-height) !important;
    /* Dark fallback so body background never bleeds through */
    background-color: #1a2e5a;
}

/* First section of pages without a page-hero gets decent breathing room */
main > section:first-child:not(.page-hero),
main > div:first-child {
    padding-top: 2.5rem;
}

/* Admin & member pages: extra top padding so content sits clear of the navbar */
main.admin-main > section:first-child,
main.admin-main > div:first-child {
    padding-top: 2rem;
}
/* Hero sections that handle navbar offset themselves opt out */
main.admin-main > section.no-admin-pt:first-child,
main.admin-main > div.no-admin-pt:first-child {
    padding-top: 0 !important;
}

/* Navbar dropdown polish */
.navbar .dropdown-menu {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 0.5rem;
}
.navbar .dropdown-item {
    border-radius: 0.5rem;
    padding: 0.45rem 0.85rem;
    font-size: .9rem;
}
.navbar .dropdown-item:hover {
    background: #f0f4ff;
    color: var(--primary-color);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 992px) {
    body {
        padding-top: 56px;
    }
    .page-hero {
        margin-top: calc(-1 * 56px);
        padding-top: 56px !important;
    }
}

@media (max-width: 768px) {
    .navbar-nav {
        background: rgba(255,255,255,0.1);
        border-radius: var(--border-radius);
        margin-top: 10px;
        padding: 10px;
    }
    
    .dropdown-menu {
        min-width: 260px;
    }

    /* Toast positioning for mobile */
    .toast-container {
        top: 70px !important;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: calc(100% - 2rem);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.bg-gradient-primary {
    background: var(--gradient-primary);
}

.bg-gradient-light {
    background: var(--gradient-light);
}

.shadow-custom-sm {
    box-shadow: var(--shadow-sm);
}

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

.shadow-custom-lg {
    box-shadow: var(--shadow-lg);
}

.border-radius-custom {
    border-radius: var(--border-radius);
}

/* ========================================
   ANIMATION CLASSES
   ======================================== */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* ========================================
   FOCUS STATES FOR ACCESSIBILITY
   ======================================== */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ========================================
   BUTTON ENHANCEMENTS
   ======================================== */
.btn-primary {
    background: var(--gradient-primary);
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    font-weight: 500;
    transition: all 0.3s ease;
}

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

/* ========================================
   LOADING STATES
   ======================================== */
.btn:disabled {
    opacity: 0.6;
    pointer-events: none;
}

.loading {
    position: relative;
    opacity: 0.7;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   FORM ENHANCEMENTS
   ======================================== */
.form-control,
.form-select {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(66, 153, 225, 0.15);
}

/* ========================================
   CARD COMPONENTS
   ======================================== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

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

.card-header {
    border-bottom: 1px solid #e2e8f0;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
}
.card-header:not([class*="bg-"]) {
    background: var(--gradient-light);
}

/* ========================================
   TABLE ENHANCEMENTS
   ======================================== */
.table {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead th {
    background: var(--gradient-light);
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: background .15s;
}

.table tbody tr:hover {
    background: rgba(66, 153, 225, 0.05);
    transform: none;
}

/* ========================================
   BADGE ENHANCEMENTS
   ======================================== */
.badge {
    border-radius: 20px;
    font-weight: 500;
    padding: 6px 12px;
    font-size: 0.75rem;
}

/* ========================================
   PAGINATION STYLES
   ======================================== */
.pagination .page-link {
    border: 0;
    border-radius: .5rem !important;
    background: #f4f6fb;
    color: #495057;
    padding: .4rem .75rem;
    margin: 0 2px;
    min-width: 2.25rem;
    text-align: center;
    transition: background .15s;
    transform: none !important;
}

.pagination .page-link:hover {
    background: #e2e6ea;
    color: #212529;
    transform: none !important;
}

.pagination .page-item.active .page-link {
    background: #1a2e5a !important;
    color: #fff !important;
    box-shadow: none;
}

.pagination .page-item.disabled .page-link {
    background: #f4f6fb;
    color: #adb5bd;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .navbar,
    .toast-container,
    .btn,
    .dropdown-menu {
        display: none !important;
    }
    
    body {
        padding-top: 0;
    }
    
    main {
        background: white;
    }
}