@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;
    --bg-color: #f3f4f6;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f3f4f6;
    --card-bg: #ffffff;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
}

.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.sidebar h2 {
    margin-bottom: 40px;
    text-align: center;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 1px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 20px;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav ul li {
    margin-bottom: 8px;
}

.sidebar nav ul li a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 1rem;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 600;
}

.sidebar nav ul li a:hover,
.sidebar nav ul li a.active {
    background-color: var(--primary-color);
    color: #fff;
    transform: translateX(5px);
}

.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: var(--bg-color);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 18px 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    min-height: 70px;
}

.page-title h3 {
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
    line-height: 1.2;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    height: 100%;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 6px 12px;
    background: #eef2ff;
    border-radius: 6px;
    transition: background 0.2s;
}

.user-info a:hover {
    background: #e0e7ff;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #cbd5e1;
    display: flex;
    /* Placeholder center */
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
}

/* Cards & Containers */
.card,
.task-info-card,
.attachments-section,
.report-section,
.form-container {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #f9fafb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: #fff;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger);
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success);
}

.btn-warning {
    background-color: var(--warning);
    color: #fff;
}

.btn-secondary {
    background-color: #64748b;
}

/* Login Page */
.login-container {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-color);
    font-size: 1.8rem;
}

.alert {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    align-items: flex-start;
}

.kanban-column {
    min-width: 300px;
    flex: 1;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.column-header {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.task-card {
    background: #ffffff;
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.task-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.task-card:hover::before {
    opacity: 1;
}

.task-card:hover {
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.12);
    border-color: #e0e7ff;
    transform: translateY(-4px) scale(1.01);
    background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
}

.task-card h4 {
    margin-bottom: 10px;
    font-size: 1.08rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
    transition: color 0.2s;
}

.task-card:hover h4 {
    color: var(--primary-color);
}

.task-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

.priority {
    padding: 5px 12px;
    border-radius: 20px;
    color: white;
    font-size: 0.7rem;
    letter-spacing: 0.3px;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
}

.priority:hover {
    transform: scale(1.05);
}

.p-low {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.p-medium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.p-high {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.due-date {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    padding: 4px 10px;
    background: #f1f5f9;
    border-radius: 6px;
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-number {
    font-size: 3rem;
    font-weight: 800;
    margin-top: 10px;
    line-height: 1;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 16px;
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

tr:last-child td {
    border-bottom: none;
}

/* RTL Support via class on body */
body.rtl {
    direction: rtl;
    text-align: right;
}

body.rtl .sidebar nav ul li a {
    transition: transform 0.2s ease;
}

body.rtl .sidebar nav ul li a:hover,
body.rtl .sidebar nav ul li a.active {
    transform: translateX(-5px);
}

body.rtl th {
    text-align: right;
}

body.rtl .user-info {
    flex-direction: row-reverse;
}

/* Top Bar Enhancements */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 15px 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    margin-bottom: 30px;
    border: none;
    gap: 20px;
}

.page-title h3 {
    font-size: 1.5rem;
    color: var(--sidebar-bg);
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Search Bar */
.header-search {
    flex: 1;
    max-width: 400px;
    position: relative;
    display: none;
}

@media (min-width: 768px) {
    .header-search {
        display: block;
    }
}

.header-search input {
    width: 100%;
    padding: 10px 15px 10px 45px;
    border-radius: 50px;
    border: 1px solid #f1f5f9;
    background: #f8fafc;
    transition: all 0.3s;
}

.header-search input:focus {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: var(--primary-color);
}

.header-search i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 15px;
    color: #94a3b8;
    pointer-events: none;
    font-size: 1.2rem;
}

body.rtl .header-search input {
    padding: 10px 45px 10px 15px;
}

body.rtl .header-search i {
    left: auto;
    right: 15px;
}

/* Actions Area */
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #e2e8f0;
    color: var(--primary-color);
}

.icon-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    border: 2px solid #fff;
}

/* User Profile */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lang-switch {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-muted);
    text-decoration: none;
}

.lang-switch:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.profile-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px;
    border-radius: 30px;
    transition: background 0.2s;
}

.profile-dropdown:hover {
    background: #f8fafc;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: block;
    color: var(--text-color);
}

/* FIX OVERLAYS */
.modal-backdrop,
.overlay,
.fade.show {
    display: none !important;
}

body>div[style*="fixed"] {
    display: none !important;
}

.main-content {
    position: relative;
    z-index: 1;
}

/* Dropdown Menu */
.profile-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 10px;
    display: none;
    z-index: 100;
    padding: 8px 0;
}

.dropdown-menu.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-color);
    text-decoration: none;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.dropdown-item:hover {
    background-color: #f8fafc;
    color: var(--primary-color);
}

.dropdown-item i {
    margin-right: 10px;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* RTL Support for dropdown */
body.rtl .dropdown-menu {
    right: auto;
    left: 0;
}

body.rtl .dropdown-item i {
    margin-right: 0;
    margin-left: 10px;
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablet Devices (768px - 1024px) */
@media (max-width: 1024px) {
    .kanban-board {
        gap: 15px;
    }

    .kanban-column {
        min-width: 260px;
    }

    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .top-bar {
        flex-wrap: wrap;
        gap: 15px;
    }
}

/* Mobile Devices (below 768px) */
@media (max-width: 768px) {

    /* Sidebar Collapse */
    .sidebar {
        width: 70px;
        padding: 24px 10px;
    }

    .sidebar h2 {
        display: none;
    }

    .sidebar nav ul li a {
        padding: 12px;
        justify-content: center;
        font-size: 0;
    }

    .sidebar nav ul li a i {
        margin: 0 !important;
        font-size: 1.4rem;
    }

    /* Main Content */
    .main-content {
        padding: 15px;
    }

    /* Top Bar */
    .top-bar {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
    }

    .page-title h3 {
        font-size: 1.2rem;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .user-name {
        display: none;
    }

    /* Kanban Board - Stack Vertically */
    .kanban-board {
        flex-direction: column;
        gap: 15px;
    }

    .kanban-column {
        min-width: 100%;
        width: 100%;
    }

    /* Dashboard Stats */
    .dashboard-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-number {
        font-size: 2.5rem;
    }

    /* Tables - Horizontal Scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th,
    td {
        padding: 12px 10px;
        font-size: 0.9rem;
    }

    /* Forms */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 12px 20px;
        width: 100%;
        justify-content: center;
    }

    /* Task Cards */
    .task-card {
        padding: 14px;
    }

    .task-card h4 {
        font-size: 1rem;
    }

    /* Login Box */
    .login-box {
        padding: 30px 20px;
        margin: 15px;
    }

    .login-box h2 {
        font-size: 1.5rem;
    }

    /* Form Container */
    .form-container {
        padding: 20px 15px;
    }
}

/* Small Mobile Devices (below 480px) */
@media (max-width: 480px) {
    .sidebar {
        width: 60px;
        padding: 15px 5px;
    }

    .sidebar nav ul li a i {
        font-size: 1.2rem;
    }

    .top-bar {
        padding: 10px;
    }

    .page-title h3 {
        font-size: 1.1rem;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .lang-switch {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .kanban-column {
        padding: 12px;
    }

    .column-header {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .task-card {
        padding: 12px;
    }

    .task-card h4 {
        font-size: 0.95rem;
    }

    .priority {
        padding: 4px 8px;
        font-size: 0.65rem;
    }

    .due-date {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .stat-number {
        font-size: 2rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* Landscape Phone */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 60px;
        padding: 15px 5px;
    }

    .main-content {
        padding: 10px;
    }

    .kanban-board {
        flex-direction: row;
    }

    .kanban-column {
        min-width: 280px;
    }
}

/* Print Styles */
@media print {

    .sidebar,
    .top-bar,
    .btn,
    .task-actions {
        display: none;
    }

    .main-content {
        padding: 0;
    }

    .task-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ==================== TASKS TOOLBAR STYLES ==================== */
.tasks-toolbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.tasks-toolbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    flex-wrap: wrap;
}

.tasks-filter-form {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.search-input-group,
.date-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-group i,
.date-input-group i {
    position: absolute;
    left: 15px;
    color: #94a3b8;
    pointer-events: none;
    z-index: 10;
}

.search-input-group input,
.date-input-group input {
    padding: 10px 15px 10px 42px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    transition: all 0.3s;
    height: 42px;
}

.search-input-group input:focus,
.date-input-group input:focus {
    background: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

body.rtl .search-input-group i,
body.rtl .date-input-group i {
    left: auto;
    right: 15px;
}

body.rtl .search-input-group input,
body.rtl .date-input-group input {
    padding: 10px 42px 10px 15px;
}

/* Responsive adjustments for Toolbar */
@media (max-width: 991px) {
    .tasks-toolbar-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 15px;
    }

    .tasks-toolbar-left {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 15px;
    }

    .tasks-filter-form {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }

    .search-input-group,
    .date-input-group,
    .search-input-group input,
    .date-input-group input {
        width: 100%;
    }

    .tasks-header h3 {
        text-align: center;
        margin-bottom: 5px !important;
    }

    /* Ensure buttons take full width on mobile */
    .tasks-toolbar-container .btn,
    .tasks-toolbar-container .btn-text {
        width: 100%;
        justify-content: center;
    }

    /* Reset margin-left auto for RTL/LTR on mobile */
    .tasks-toolbar-container>.btn-primary {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}