/* ================================================================
   LIENS - Educational Links Portal
   Main Stylesheet - RTL Arabic
   ================================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #10b981;
    --secondary-light: #d1fae5;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --purple: #8b5cf6;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --sidebar-width: 270px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --topbar-h: 65px;
    --radius: 12px;
    --shadow: 0 2px 15px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: #1e293b;
    margin: 0;
    padding: 0;
}

/* ================================================================
   COORDINATOR / PUBLIC INTERFACE
   ================================================================ */

.coordinator-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0f172a 100%);
    background-attachment: fixed;
}

.app-header {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: white;
}

.app-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.5px;
}

.app-subtitle {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}

.header-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(37,99,235,0.4);
}

.main-content {
    flex: 1;
    padding: 40px 0;
}

/* Access Card */
.access-card {
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.access-card-header {
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
    text-align: center;
    padding: 36px 28px 28px;
}

.access-card-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.access-card-header p {
    opacity: 0.85;
    margin: 0;
    font-size: 0.95rem;
}

.access-card-body {
    padding: 32px 28px;
}

/* Steps */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.step-item.active {
    background: #eff6ff;
    border-color: var(--primary);
}

.step-item.completed {
    background: #f0fdf4;
    border-color: var(--secondary);
}

.step-number {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.step-item.active .step-number {
    background: var(--primary);
    color: white;
}

.step-item.completed .step-number {
    background: var(--secondary);
    color: white;
}

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

.loading-spinner {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-size: 0.85rem;
    margin-top: 6px;
}

.access-btn {
    background: linear-gradient(135deg, var(--primary), var(--info));
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    transition: all 0.3s;
}

.access-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37,99,235,0.4);
}

.access-btn:disabled {
    opacity: 0.55;
    background: linear-gradient(135deg, #94a3b8, #cbd5e1);
}

/* Links Section */
.links-header {
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 24px 28px;
    margin-bottom: 28px;
    color: white;
}

.links-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    margin-bottom: 4px;
}

.links-subtitle {
    color: rgba(255,255,255,0.65);
    margin: 0;
    font-size: 0.9rem;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.link-card {
    opacity: 0;
    transform: translateY(20px);
}

.link-card.animate-in {
    animation: fadeSlideIn 0.4s ease forwards;
}

@keyframes fadeSlideIn {
    to { opacity: 1; transform: translateY(0); }
}

.link-card-anchor {
    display: flex;
    align-items: center;
    gap: 16px;
    background: white;
    border-radius: 14px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: all 0.25s ease;
    border-top: 4px solid var(--primary);
}

.link-card-anchor:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
    color: inherit;
}

.link-card-icon {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.25s;
}

.link-card-anchor:hover .link-card-icon {
    transform: scale(1.1);
}

.link-card-body {
    flex: 1;
    min-width: 0;
}

.link-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

.link-card-desc {
    font-size: 0.83rem;
    color: #64748b;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-card-arrow {
    color: #94a3b8;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: all 0.25s;
}

.link-card-anchor:hover .link-card-arrow {
    color: var(--primary);
    transform: translateX(-3px);
}

.no-links-message {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255,255,255,0.6);
}

/* Footer */
.app-footer {
    background: rgba(0,0,0,0.25);
    color: rgba(255,255,255,0.5);
    padding: 16px 0;
    font-size: 0.85rem;
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0f172a 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.login-header {
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
    text-align: center;
    padding: 40px 32px 32px;
}

.login-logo {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(5px);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 16px;
    border: 2px solid rgba(255,255,255,0.3);
}

.login-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.login-header p {
    opacity: 0.8;
    margin: 0;
    font-size: 0.9rem;
}

.login-body-content {
    padding: 36px 32px;
}

/* ================================================================
   ADMIN LAYOUT
   ================================================================ */

.admin-body {
    background: var(--bg);
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-title {
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-subtitle {
    color: var(--sidebar-text);
    font-size: 0.75rem;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--sidebar-text);
    margin-right: auto;
    padding: 4px 8px;
    cursor: pointer;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    border-radius: 0;
    transition: all 0.2s;
    font-size: 0.92rem;
    font-weight: 500;
    border-right: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    color: white;
    background: rgba(255,255,255,0.07);
    border-right-color: rgba(255,255,255,0.3);
}

.sidebar-nav .nav-link.active {
    color: white;
    background: rgba(37,99,235,0.25);
    border-right-color: var(--primary);
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}

.admin-avatar {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.admin-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-name {
    color: white;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-role {
    color: var(--sidebar-text);
    font-size: 0.75rem;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px;
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239,68,68,0.3);
    color: white;
}

/* Main Area */
.admin-main {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin 0.3s;
}

/* Top Bar */
.admin-topbar {
    height: var(--topbar-h);
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 10px rgba(0,0,0,0.05);
}

.topbar-toggle {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: none;
    transition: all 0.2s;
}

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

.topbar-title {
    flex: 1;
}

.topbar-title h5 {
    font-weight: 700;
    color: #1e293b;
}

/* Content Area */
.admin-content {
    flex: 1;
    padding: 28px;
}

.flash-container {
    position: sticky;
    top: var(--topbar-h);
    z-index: 99;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

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

/* ================================================================
   ADMIN COMPONENTS
   ================================================================ */

/* Stat Cards */
.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-blue .stat-icon  { background: #dbeafe; color: var(--primary); }
.stat-green .stat-icon { background: #d1fae5; color: var(--secondary); }
.stat-orange .stat-icon { background: #fef3c7; color: var(--warning); }
.stat-teal .stat-icon  { background: #cffafe; color: var(--info); }

.stat-info h3 {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    line-height: 1;
    color: #1e293b;
}

.stat-info p {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 500;
}

/* Admin Card */
.admin-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.admin-card-header {
    padding: 18px 22px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafafa;
}

.admin-card-header h5 {
    margin: 0;
    font-weight: 700;
    font-size: 1rem;
    color: #1e293b;
}

.admin-card-body {
    padding: 22px;
}

/* Table Styles */
.table-header th {
    background: #f8fafc;
    font-weight: 700;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 14px 16px;
    border: none;
    border-bottom: 2px solid #e2e8f0;
}

.table tbody tr:hover td {
    background: #f8fafc;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.92rem;
}

.table-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.bg-primary-soft { background: #dbeafe; }
.bg-success-soft { background: #d1fae5; }

.access-code-badge {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 1px;
}

/* Link mini icon */
.link-mini-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Status Badges */
.badge.status-badge-visible  { background: #d1fae5 !important; color: #065f46 !important; }
.badge.status-badge-hidden   { background: #fef3c7 !important; color: #92400e !important; }
.badge.status-badge-disabled { background: #fee2e2 !important; color: #991b1b !important; }

/* ================================================================
   LINKS MANAGEMENT PAGE
   ================================================================ */

/* Links Management Grid */
.links-management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.link-manage-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.25s;
}

.link-manage-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.link-manage-card.status-hidden {
    opacity: 0.75;
}

.link-manage-card.status-disabled {
    opacity: 0.55;
}

.link-manage-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
}

.link-manage-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.link-manage-info {
    flex: 1;
    min-width: 0;
}

.link-manage-info h6 {
    font-weight: 700;
    margin-bottom: 3px;
    font-size: 0.95rem;
}

.link-manage-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
    gap: 8px;
    flex-wrap: wrap;
}

/* Status Buttons */
.status-btn-visible {
    background: #d1fae5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-size: 0.82rem;
    font-weight: 600;
}

.status-btn-hidden {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.82rem;
    font-weight: 600;
}

.status-btn-disabled {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Link Form Styles */
.inst-assignment-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 20px;
}

.inst-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px;
}

.inst-checkbox-item {
    padding: 10px 14px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: all 0.15s;
}

.inst-checkbox-item:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.inst-checkbox-item .form-check-label {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    width: 100%;
    padding-right: 4px;
}

.inst-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e293b;
}

.inst-dir {
    font-size: 0.77rem;
    color: #64748b;
}

/* Link Preview */
.link-preview-box {
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 16px;
    border-top: 4px solid var(--primary);
    transition: border-color 0.2s;
}

.preview-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    font-weight: 600;
}

.link-card-preview {
    display: flex;
    align-items: center;
    gap: 12px;
}

.link-card-icon-prev {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.link-card-title-prev {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
}

/* Color Presets */
.color-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(0,0,0,0.1);
    transition: transform 0.15s, box-shadow 0.15s;
}

.color-dot:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* ================================================================
   IMPORT PAGE
   ================================================================ */

.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.25s;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--secondary);
    background: #f0fdf4;
}

.instruction-box {
    background: #f8fafc;
    border-radius: var(--radius);
    padding: 20px;
    height: 100%;
}

/* ================================================================
   RESPONSIVE - MOBILE
   ================================================================ */

@media (max-width: 991px) {
    .admin-sidebar {
        transform: translateX(100%);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-main {
        margin-right: 0;
    }

    .topbar-toggle {
        display: flex;
    }

    .sidebar-close {
        display: block;
    }
}

@media (max-width: 767px) {
    .admin-content {
        padding: 16px;
    }

    .links-management-grid {
        grid-template-columns: 1fr;
    }

    .links-grid {
        grid-template-columns: 1fr;
    }

    .access-card-body {
        padding: 20px 16px;
    }

    .main-content {
        padding: 24px 0;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 1.1rem;
    }

    .stat-info h3 {
        font-size: 1.6rem;
    }

    .app-title {
        font-size: 1.1rem;
    }

    .inst-checkboxes {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .access-card-header {
        padding: 28px 20px 22px;
    }

    .access-card-header h2 {
        font-size: 1.3rem;
    }
}

/* ================================================================
   FORM STYLES
   ================================================================ */

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control-lg, .form-select-lg {
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
}

.form-control, .form-select {
    font-family: 'Tajawal', sans-serif;
    border-radius: 8px;
}

.btn {
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    border-radius: 8px;
}

.btn-lg {
    border-radius: 10px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Alert styling */
.alert {
    border-radius: 10px;
    font-size: 0.92rem;
}

/* Badge */
.badge {
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
}

/* Table responsive fix */
.table-responsive {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* min-w-0 utility */
.min-w-0 { min-width: 0; }
