/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * Harmuni Task Management System - Custom Styles
 * ═══════════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════════
   Global Styles
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    --primary-color: #C9A961;      /* ذهبي فاخر من الشعار */
    --primary-dark: #B8984E;       /* ذهبي داكن */
    --secondary-color: #5B6E7F;    /* أزرق رمادي أنيق */
    --secondary-dark: #4A5A68;     /* أزرق رمادي داكن */
    --accent-gold: #D4AF37;        /* ذهبي لامع للتفاصيل */
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #C9A961;      /* استخدام الذهبي للتحذيرات */
    --info-color: #5B6E7F;         /* أزرق رمادي للمعلومات */
    --light-color: #f8f9fa;
    --dark-color: #2C3E50;         /* داكن أنيق */
    --bg-gradient: linear-gradient(135deg, #5B6E7F 0%, #C9A961 100%);
}

* {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
                 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: rgba(201, 169, 97, 0.2);
}

html {
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

body {
    direction: rtl;
    text-align: right;
    background-color: #f5f7fa;
    min-height: 100vh;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.main-container {
    padding: 2rem 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Cards
   ═══════════════════════════════════════════════════════════════════════════════ */

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-header {
    background: linear-gradient(90deg, rgba(91, 110, 127, 0.05) 0%, rgba(201, 169, 97, 0.05) 100%);
    border-bottom: 2px solid #C9A961;
    font-weight: 600;
    padding: 1rem 1.5rem;
    color: #2C3E50;
}

.card-body {
    padding: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Statistics Cards
   ═══════════════════════════════════════════════════════════════════════════════ */

.stat-card {
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
}

.stat-card .stat-icon {
    font-size: 3rem;
    opacity: 0.8;
}

.stat-card .stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0.5rem 0;
}

.stat-card .stat-label {
    font-size: 1rem;
    opacity: 0.9;
}

.stat-card-primary {
    background: linear-gradient(135deg, #5B6E7F 0%, #4A5A68 100%);
}

.stat-card-success {
    background: linear-gradient(135deg, #C9A961 0%, #B8984E 100%);
}

.stat-card-warning {
    background: linear-gradient(135deg, #D4AF37 0%, #C9A961 100%);
}

.stat-card-info {
    background: linear-gradient(135deg, #6B7E8F 0%, #5B6E7F 100%);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Tables
   ═══════════════════════════════════════════════════════════════════════════════ */

.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    background-color: #f8f9fa;
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════════════════════════ */

.btn {
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s;
    min-height: 44px;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-appearance: none;
}

.btn-primary {
    background: linear-gradient(135deg, #C9A961 0%, #B8984E 100%);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #D4AF37 0%, #C9A961 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 169, 97, 0.4);
}

.btn-info {
    background-color: #5B6E7F;
    border-color: #5B6E7F;
    color: white;
}

.btn-info:hover {
    background-color: #4A5A68;
    border-color: #4A5A68;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(91, 110, 127, 0.3);
}

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

/* RTL fix: button group border-radius */
.btn-group > .btn:first-child:not(:last-child) {
    border-radius: 0 8px 8px 0;
}
.btn-group > .btn:last-child:not(:first-child) {
    border-radius: 8px 0 0 8px;
}
.btn-group > .btn:not(:first-child):not(:last-child) {
    border-radius: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════════════════════════ */

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 0.625rem 1rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-appearance: none;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* RTL fix: move select dropdown arrow to left side */
.form-select {
    background-position: left 0.75rem center;
    padding-left: 2.25rem;
    padding-right: 1rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #C9A961;
    box-shadow: 0 0 0 0.2rem rgba(201, 169, 97, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Badges
   ═══════════════════════════════════════════════════════════════════════════════ */

.badge {
    padding: 0.4rem 0.8rem;
    font-weight: 500;
    border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Navbar
   ═══════════════════════════════════════════════════════════════════════════════ */

.navbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: linear-gradient(90deg, #5B6E7F 0%, #4A5A68 100%) !important;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.back-btn {
    font-size: 1.2rem;
    opacity: 0.8;
    transition: opacity 0.2s;
    text-decoration: none !important;
}

.back-btn:hover {
    opacity: 1;
}

.navbar-nav .nav-link {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    background-color: rgba(201, 169, 97, 0.2);
    border-bottom: 2px solid #C9A961;
}

#notificationBadge {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    margin-right: 0.25rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Login Page
   ═══════════════════════════════════════════════════════════════════════════════ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5B6E7F 0%, #C9A961 100%);
}

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

.login-header {
    text-align: center;
    padding: 2rem 2rem 1rem;
    background: linear-gradient(135deg, #5B6E7F 0%, #C9A961 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.login-body {
    padding: 2rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Toast Container
   ═══════════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
}

.toast {
    border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Modals
   ═══════════════════════════════════════════════════════════════════════════════ */

.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    border-bottom: 2px solid #f0f0f0;
    border-radius: 12px 12px 0 0;
}

.modal-footer {
    border-top: 2px solid #f0f0f0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Loading Spinner
   ═══════════════════════════════════════════════════════════════════════════════ */

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Empty State
   ═══════════════════════════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

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

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

.empty-state p {
    color: #adb5bd;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Action Buttons
   ═══════════════════════════════════════════════════════════════════════════════ */

.action-buttons .btn {
    margin-left: 0.25rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Search Box
   ═══════════════════════════════════════════════════════════════════════════════ */

.search-box {
    position: relative;
}

.search-box input {
    padding-right: 2.5rem;
}

.search-box i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .stat-card {
        margin-bottom: 1rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .action-buttons .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        min-height: 44px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   iPad & Tablet Responsive
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 768px) and (max-width: 1194px) {
    .login-card {
        max-width: 520px;
    }

    .btn-lg {
        min-height: 50px;
        padding: 0.875rem 2rem;
        font-size: 1.1rem;
    }

    .form-control-lg {
        min-height: 50px;
        font-size: 1rem;
    }
}

/* iPad landscape & large screens */
@media (min-width: 1024px) {
    .login-card {
        max-width: 500px;
    }

    .btn-lg {
        min-height: 50px;
        padding: 1rem 2.5rem;
        font-size: 1.1rem;
    }
}

/* Landscape orientation - compact height */
@media (orientation: landscape) and (max-height: 600px) {
    .login-container {
        min-height: auto;
        padding: 1rem 0;
    }

    .login-header {
        padding: 1rem 2rem 0.5rem;
    }

    .login-header .fa-3x {
        font-size: 2rem !important;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    .login-body {
        padding: 1rem 2rem;
    }

    .login-body .mb-3 {
        margin-bottom: 0.5rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   iOS Native App Feel
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Touch targets - all interactive elements must be at least 44x44pt */
a, button, input[type="submit"], input[type="button"],
.form-check-input, .form-check-label, .nav-link, .dropdown-item {
    touch-action: manipulation;
}

.nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
}

.form-check-input {
    min-width: 20px;
    min-height: 20px;
}

.form-check-label {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 0.25rem;
}

/* Prevent text selection on UI elements (native feel) */
.btn, .nav-link, .navbar-brand, .badge {
    -webkit-user-select: none;
    user-select: none;
}

/* Smooth scrolling */
.main-container, .card-body, .modal-body, .table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Active state for touch feedback (native-like press effect) */
.btn:active {
    transform: scale(0.97);
    transition: transform 0.1s;
}

.btn-primary:active {
    background: linear-gradient(135deg, #B8984E 0%, #A68943 100%);
}

/* Login container - safe area handling */
.login-container {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Navbar safe area */
.navbar {
    padding-top: calc(0.5rem + env(safe-area-inset-top));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Touch Device: Disable hover transforms (CRITICAL for iOS)
   On touch devices, :hover triggers on tap. translateY causes the button
   to shift, making the tap miss the target — this is the #1 reason
   Apple rejected the app (login button unresponsive).
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .btn-primary:hover,
    .btn-info:hover {
        transform: none !important;
    }

    .card:hover {
        transform: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Offline Indicator (Apple requires graceful offline handling)
   ═══════════════════════════════════════════════════════════════════════════════ */

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #dc3545;
    color: white;
    text-align: center;
    padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    display: none;
}

.offline-banner.visible {
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════════════════════════════════════════ */

.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Accessibility - Focus Indicators (M20)
   ═══════════════════════════════════════════════════════════════════════════════ */

:focus-visible {
    outline: 2px solid #C9A961;
    outline-offset: 2px;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.5);
}

.form-control:focus-visible,
.form-select:focus-visible {
    border-color: #C9A961;
    box-shadow: 0 0 0 0.25rem rgba(201, 169, 97, 0.25);
}

.nav-link:focus-visible {
    outline-color: #D4AF37;
    background-color: rgba(201, 169, 97, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Dark Mode
   ═══════════════════════════════════════════════════════════════════════════════ */

[data-theme="dark"] body {
    background-color: #121212;
    color: #e0e0e0;
}

[data-theme="dark"] .card {
    background: #1e1e1e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #2d2d2d;
}

[data-theme="dark"] .card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .card-header {
    background: linear-gradient(90deg, rgba(91, 110, 127, 0.15) 0%, rgba(201, 169, 97, 0.15) 100%);
    border-bottom: 2px solid #C9A961;
    color: #e0e0e0;
}

[data-theme="dark"] .table thead th {
    background-color: #1a1a1a;
    color: #ccc;
    border-bottom-color: #333;
}

[data-theme="dark"] .table tbody tr {
    color: #e0e0e0;
}

[data-theme="dark"] .table tbody tr:hover {
    background-color: #252525;
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #252525;
    --bs-table-color: #e0e0e0;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .table td strong,
[data-theme="dark"] .table td a {
    color: #fff;
}

[data-theme="dark"] .table td small,
[data-theme="dark"] .table td .text-muted {
    color: #aaa !important;
}

[data-theme="dark"] .assignee-badges .badge {
    color: #fff;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: #333;
    border-color: #C9A961;
    color: #e0e0e0;
}

[data-theme="dark"] .form-control::placeholder {
    color: #888;
}

[data-theme="dark"] .modal-content {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #333;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #333;
}

[data-theme="dark"] .bg-light {
    background-color: #252525 !important;
}

[data-theme="dark"] .text-muted {
    color: #999 !important;
}

[data-theme="dark"] .text-dark {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .border {
    border-color: #333 !important;
}

[data-theme="dark"] .border-bottom {
    border-bottom-color: #333 !important;
}

[data-theme="dark"] .dropdown-menu {
    background-color: #1e1e1e;
    border-color: #333;
}

[data-theme="dark"] .dropdown-item {
    color: #e0e0e0;
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #2d2d2d;
}

[data-theme="dark"] .dropdown-divider {
    border-color: #333;
}

[data-theme="dark"] .dropdown-item-text {
    color: #999;
}

[data-theme="dark"] .empty-state {
    color: #888;
}

[data-theme="dark"] .empty-state p {
    color: #666;
}

[data-theme="dark"] .btn-outline-secondary {
    color: #bbb;
    border-color: #555;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .btn-outline-primary {
    color: #C9A961;
    border-color: #C9A961;
}

[data-theme="dark"] .btn-outline-danger {
    color: #ef5350;
    border-color: #ef5350;
}

[data-theme="dark"] .btn-secondary {
    background-color: #333;
    border-color: #444;
}

[data-theme="dark"] .list-group-item {
    background-color: #1e1e1e;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .page-link {
    background-color: #1e1e1e;
    border-color: #333;
    color: #e0e0e0;
}

[data-theme="dark"] .page-item.active .page-link {
    background-color: #C9A961;
    border-color: #C9A961;
}

[data-theme="dark"] .form-check-label {
    color: #ddd;
}

[data-theme="dark"] .search-box i {
    color: #888;
}

[data-theme="dark"] .toast {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

/* Theme toggle button */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.2s;
    background: transparent;
}

[data-theme="dark"] .navbar {
    background: linear-gradient(90deg, #1a1a2e 0%, #16213e 100%) !important;
}

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
    color: #e0e0e0;
}

[data-theme="dark"] strong {
    color: #fff;
}

/* Force all text visible in dark mode */
[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] td,
[data-theme="dark"] th,
[data-theme="dark"] li,
[data-theme="dark"] label,
[data-theme="dark"] div,
[data-theme="dark"] a:not(.btn):not(.nav-link):not(.navbar-brand) {
    color: #ddd;
}

[data-theme="dark"] .card-body,
[data-theme="dark"] .card-body * {
    color: #e0e0e0;
}

[data-theme="dark"] .card-body strong,
[data-theme="dark"] .card-body a:not(.btn) {
    color: #fff !important;
}

[data-theme="dark"] .card-body .text-muted,
[data-theme="dark"] .card-body small {
    color: #aaa !important;
}

[data-theme="dark"] .card-body .badge {
    color: #fff !important;
}

[data-theme="dark"] .employee-card {
    background: #1e1e1e;
    border-color: #333;
}

[data-theme="dark"] .employee-card .card-label {
    color: #999;
}

[data-theme="dark"] .btn-outline-light {
    color: #e0e0e0;
    border-color: #555;
}

[data-theme="dark"] .form-check-input {
    background-color: #333;
    border-color: #555;
}

[data-theme="dark"] .alert {
    background-color: #2d2d2d;
    border-color: #444;
    color: #e0e0e0;
}

