/**
 * ESS Portal Custom Styles
 * Mobile-first responsive design
 */

/* Alpine.js Cloak - Hide elements before Alpine initializes */
[x-cloak] {
    display: none !important;
}

/* CSS Variables */
:root {
    --ess-primary: #097B3E;
    --ess-primary-dark: #006633;
    --ess-secondary: #444444;
    --ess-accent: #D89837;
    --ess-success: #198754;
    --ess-warning: #ffc107;
    --ess-danger: #C44D1A;
    --ess-light: #F5F5F5;
    --ess-dark: #212529;
    --ess-purple: #6f42c1;
    --ess-sidebar-width: 280px;
    --ess-bottom-nav-height: 60px;
    --ess-header-height: 56px;
    --bs-primary: var(--ess-primary);
    --bs-primary-rgb: 9, 123, 62;
    --bs-link-color: var(--ess-primary);
    --bs-link-hover-color: var(--ess-primary-dark);
}

/* Custom Colors */
.bg-purple {
    background-color: var(--ess-purple) !important;
}

.text-purple {
    color: var(--ess-purple) !important;
}

.bg-purple.bg-opacity-10 {
    background-color: rgba(111, 66, 193, 0.1) !important;
}

/* Base Styles */
html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--ess-light);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ess-primary) 0%, var(--ess-primary-dark) 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-logo {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.login-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

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

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--ess-sidebar-width);
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar.show {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1rem;
    background: var(--ess-primary);
    color: white;
}

.sidebar-logo img {
    filter: brightness(0) invert(1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-avatar i {
    font-size: 1.5rem;
}

.sidebar-user-info h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-user-info small {
    opacity: 0.8;
}

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

.sidebar-menu-section {
    padding: 0.75rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ess-secondary);
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--ess-dark);
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.75rem;
}

.sidebar-menu-item:hover {
    background: var(--ess-light);
    color: var(--ess-primary);
}

.sidebar-menu-item.active {
    background: rgba(9, 123, 62, 0.1);
    color: var(--ess-primary);
    border-left: 3px solid var(--ess-primary);
}

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

.sidebar-submenu {
    padding-left: 2.5rem;
}

.sidebar-submenu .sidebar-menu-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Content Area */
.content-wrapper {
    flex: 1;
    padding-bottom: calc(var(--ess-bottom-nav-height) + 1rem);
}

/* Top Header */
.top-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--ess-header-height);
}

.top-header-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.top-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--ess-bottom-nav-height);
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.5rem;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--ess-secondary);
    text-decoration: none;
    transition: color 0.2s;
    min-width: 0;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: var(--ess-primary);
}

.bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
}

.bottom-nav-item span {
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Page Content */
.page-content {
    padding: 1rem;
}

/* Cards */
.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 1rem;
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.stat-card-label {
    font-size: 0.8rem;
    color: var(--ess-secondary);
    margin: 0;
}

/* Quick Actions */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    background: white;
    border-radius: 0.75rem;
    text-decoration: none;
    color: var(--ess-dark);
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.quick-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: var(--ess-primary);
}

.quick-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.quick-action-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

/* List Items */
.list-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--ess-dark);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.list-item:hover {
    background: var(--ess-light);
}

.list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 500;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 0.8rem;
    color: var(--ess-secondary);
    margin: 0;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-rejected {
    background: #f8d7da;
    color: #721c24;
}

/* Form Styles */
.form-floating > label {
    color: var(--ess-secondary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ess-primary);
    box-shadow: 0 0 0 0.2rem rgba(9, 123, 62, 0.2);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--ess-primary-dark);
    border-color: var(--ess-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(9, 123, 62, 0.3);
}

.btn-outline-secondary:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: var(--ess-sidebar-width);
        padding-bottom: 1rem;
    }

    .bottom-nav {
        display: none;
    }

    .sidebar-overlay {
        display: none;
    }

    .page-content {
        padding: 1.5rem;
    }
}

@media (min-width: 992px) {
    .page-content {
        padding: 2rem;
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* Navigation Tabs */
.nav-pills {
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.nav-link {
    background-color: #f0f0f0;
    color: var(--ess-dark);
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 500;
    padding: 0.6rem 1rem !important;
}

.nav-link:hover {
    background-color: #e8e8e8;
    color: var(--ess-dark);
}

.nav-link.active {
    background-color: var(--ess-primary) !important;
    color: white !important;
    border-color: var(--ess-primary) !important;
    box-shadow: 0 2px 8px rgba(9, 123, 62, 0.25);
}

.nav-fill > .nav-link {
    flex: 1 1 auto;
    text-align: center;
}

.nav-pills .badge {
    margin-left: 0.25rem;
    font-size: 0.7rem;
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--ess-bottom-nav-height) + env(safe-area-inset-bottom));
    }

    .content-wrapper {
        padding-bottom: calc(var(--ess-bottom-nav-height) + env(safe-area-inset-bottom) + 1rem);
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ess-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    margin-bottom: 0.5rem;
}

/* Profile Photo */
.profile-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.profile-photo-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--ess-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--ess-secondary);
    border: 3px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.badge-blue {
    background-color: rgba(9, 123, 62, 0.12);
    color: var(--ess-primary);
}
