/* ==================================================
   Wasit Oil Employee DB - Enhanced V3.0 Stylesheet
   PHP + MySQL Backend Edition
   ================================================== */
:root {
    --primary: #0b2f5c;
    --primary-light: #164883;
    --primary-dark: #061a35;
    --accent: #d4af37;
    --accent-hover: #b8962c;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg-page: #f0f4f8;
    --bg-surface: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.95);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-focus: var(--accent);
    --input-bg: #f8fafc;
    --login-bg: rgba(11, 47, 92, 0.4);
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px -5px rgba(11, 47, 92, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================================================
   Login Overlay
   ================================================== */
.login-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--login-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    width: 450px;
    padding: 3rem;
    text-align: right;
    border: 1px solid rgba(255,255,255,0.4);
    animation: slideDown 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h2 {
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

body.login-required main,
body.login-required .app-header,
body.login-required .app-footer {
    filter: blur(5px);
    pointer-events: none;
}

body.logged-in .login-overlay { display: none; }
body.logged-in main,
body.logged-in .app-header,
body.logged-in .app-footer {
    filter: none;
    pointer-events: auto;
}

/* ==================================================
   Reset & Typography
   ================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, Tahoma, sans-serif;
}

body {
    background-color: var(--bg-page);
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 30px 30px;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================================================
   Header
   ================================================== */
.app-header {
    background: linear-gradient(135deg, #0b2f5c 0%, #1a365d 100%);
    color: var(--text-inverse);
    padding: 1.2rem 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    border-bottom: 4px solid var(--accent);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    text-align: right;
    min-width: 250px;
}

.header-right h3, .header-right h4, .header-right h5 { margin: 0; line-height: 1.4; }
.header-right h3 { font-size: 1.15rem; font-weight: 900; color: #fff; }
.header-right h4 { font-size: 1rem; font-weight: 700; color: #e2e8f0; }
.header-right h5 { font-size: 0.9rem; font-weight: 700; color: var(--accent); }

.header-center { text-align: center; flex: 1; }
.header-center h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header-left {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1.5rem;
    min-width: 300px;
}

.user-info-header {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    padding: 0.6rem 1.2rem;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.user-info-header:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.welcome-msg { color: #ffffff; font-size: 0.9rem; font-weight: 500; }
.welcome-msg strong { color: var(--accent); font-weight: 800; }

.role-badge {
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(212, 175, 55, 0.3);
    color: var(--accent);
    font-weight: 700;
    margin: 2px 0;
}

.logout-link {
    background: none;
    border: none;
    color: #fecaca;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.logout-link:hover { color: #ffffff; background: rgba(220, 38, 38, 0.3); }

.header-left .logo-wrapper {
    background: #fff;
    padding: 6px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.header-left .logo {
    height: 70px;
    width: auto;
    object-fit: contain;
}

/* ==================================================
   Main Layout & Components
   ================================================== */
.main-container {
    max-width: 1600px;
    width: 95%;
    margin: 1.5rem auto;
    padding: 0 2rem;
    flex-grow: 1;
}

.glass-effect {
    background: var(--bg-surface-glass);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.training-module {
    background: #ffffff !important;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    transition: var(--transition);
    border-right: 6px solid #e11d48;
}

.training-module:hover {
    border-color: #e11d48;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.08);
}

.training-module h4 {
    border-bottom: 1.5px solid #f1f5f9;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

/* ==================================================
   Taskbar (Navigation)
   ================================================== */
.taskbar {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem 2rem;
    margin-bottom: 2rem;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.tab-btn:hover { background: rgba(11, 47, 92, 0.05); color: var(--primary); }
.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(11, 47, 92, 0.3);
}

.badge {
    background: var(--accent);
    color: white;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 800;
    margin-right: 0.5rem;
}

.tab-btn.active .badge { background: white; color: var(--primary); }

.view-section { display: none; animation: fadeIn 0.4s ease; }
.view-section.active { display: block; }

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    margin-bottom: 2.5rem;
}

.search-box { display: flex; gap: 0.75rem; width: 600px; max-width: 100%; }

.search-box input {
    flex-grow: 1;
    padding: 0.85rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    background-color: var(--input-bg);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(11, 47, 92, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 6px rgba(11, 47, 92, 0.2);
}
.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(11, 47, 92, 0.3);
}

.btn-success {
    background-color: var(--success);
    color: var(--text-inverse);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    background-color: var(--success-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(16, 185, 129, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--border);
    color: var(--text-muted);
}
.btn-outline:hover {
    background-color: #f8fafc;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.toolbar-actions { display: flex; gap: 1rem; }

/* ==================================================
   Form Styling
   ================================================== */
.form-wrapper { padding: 2.5rem; }
.data-form { display: flex; flex-direction: column; gap: 2.5rem; }

.form-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.form-section:hover { box-shadow: 0 8px 25px rgba(0,0,0,0.1); }

.section-title {
    background: #0b2f5c;
    color: #fff;
    padding: 1.2rem 1.8rem;
    font-size: 1.25rem;
    font-weight: 800;
    text-align: right;
    display: block;
    width: 100%;
    margin: 0;
    border-bottom: 4px solid var(--accent);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    letter-spacing: 0.5px;
}

.form-section .grid-layout,
.form-section #trainingsContainer {
    padding: 1.5rem 2rem 2.5rem 2rem;
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem 2.5rem;
}

.section-basic { border-top: 4px solid #3b82f6; }
.section-job { border-top: 4px solid #10b981; }
.section-certificate { border-top: 4px solid #ec4899; }
.section-training { border-top: 4px solid #ef4444; }

.form-group { display: flex; flex-direction: column; gap: 0.6rem; }
.full-width { grid-column: 1 / -1; }

.form-group label {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group label::before {
    content: '\25A0';
    color: var(--accent);
    font-size: 0.8rem;
    line-height: 1;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text-main);
    background-color: var(--input-bg);
    transition: var(--transition);
}

.form-group input:hover,
.form-group select:hover { border-color: var(--border-hover); }

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(11, 47, 92, 0.1);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    background-size: 1em;
}

.twin-inputs .input-group { display: flex; gap: 1rem; }
.twin-inputs .split-input { flex: 1; position: relative; }
.twin-inputs .split-input input { width: 100%; }

input:disabled, select:disabled {
    background-color: #e2e8f0;
    cursor: not-allowed;
    color: #94a3b8;
    border-color: #cbd5e1;
}

/* ==================================================
   Sub-Taskbar (Form Wizard)
   ================================================== */
.sub-taskbar {
    display: flex;
    justify-content: space-between;
    background: #f8fafc;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 50px;
    margin-bottom: 2.5rem;
    gap: 0.5rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.sub-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1rem 1.5rem;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 40px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.sub-tab-btn span {
    font-size: 1.2rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.sub-tab-btn:hover { color: var(--primary); background: rgba(255, 255, 255, 0.5); }
.sub-tab-btn:hover span { transform: scale(1.2); }

.sub-tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(11, 47, 92, 0.3);
    border-radius: 40px;
    font-size: 1.05rem;
}

.form-step { display: none; animation: fadeIn 0.4s ease; }
.form-step.active { display: block; }

.form-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ==================================================
   Employee Table
   ================================================== */
.data-table-wrapper {
    margin-top: 2rem;
    padding: 1.5rem 0;
    animation: slideUp 0.5s ease;
    overflow: visible !important;
}

.table-container {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.table-responsive { overflow-x: auto; }

.employees-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.employees-table thead {
    background-color: var(--primary-dark);
    color: #fff;
}

.employees-table th {
    padding: 1.25rem 1.5rem;
    text-align: right;
    font-weight: 800;
    font-size: 1rem;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.employees-table td {
    padding: 1rem 1.5rem;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.employees-table tbody tr { transition: background 0.2s; }
.employees-table tbody tr:hover { background-color: #f8fafc; }

.actions-group { display: flex; gap: 0.5rem; justify-content: center; }

.action-btn {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover { transform: translateY(-2px); filter: brightness(0.9); }
.view-btn { background: #e0f2fe; color: #0284c7; }
.edit-btn { background: #fef3c7; color: #d97706; }
.delete-btn { background: #fee2e2; color: #dc2626; }

.table-header-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 2px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 1.5rem;
    position: relative;
    z-index: 100;
    overflow: visible;
}

.header-title-side {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-actions-side {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: nowrap;
}

.search-wrapper { position: relative; width: 280px; max-width: 100%; }

.search-icon {
    position: absolute;
    right: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 1rem;
    pointer-events: none;
}

.search-wrapper input {
    width: 100%;
    padding: 0.65rem 2.75rem 0.65rem 1rem;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    outline: none;
}

.search-wrapper input:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.filter-wrapper select {
    padding: 0.65rem 1.25rem;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    min-width: 170px;
    transition: all 0.2s;
    outline: none;
    text-align: center;
    text-align-last: center;
}

.filter-wrapper select:hover { border-color: #cbd5e1; }

.btn-round {
    border-radius: 50px !important;
    padding: 0.65rem 1.5rem !important;
    font-size: 0.9rem !important;
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 1.15rem;
    font-weight: 600;
    background: #fff;
    display: none;
}

/* ==================================================
   Pagination
   ================================================== */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid #f1f5f9;
    background: #fff;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.page-info {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}


/* ==================================================
   Loading Spinner
   ================================================== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 2rem;
}

/* ==================================================
   Responsive
   ================================================== */
@media (max-width: 1100px) {
    .header-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    .header-right { text-align: center; }
}

@media (max-width: 900px) {
    .toolbar {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    .search-box { width: 100%; }
    .toolbar-actions {
        width: 100%;
        justify-content: stretch;
    }
    .toolbar-actions button { flex: 1; }
    .form-wrapper { padding: 1.5rem; }
    .sub-taskbar {
        flex-wrap: wrap;
        border-radius: var(--radius);
    }
    .sub-tab-btn { font-size: 0.85rem; padding: 0.7rem 1rem; }
    .taskbar { flex-wrap: wrap; gap: 0.75rem; }
    .tab-btn { font-size: 0.95rem; padding: 0.6rem 1.2rem; }
    .header-actions-side { flex-wrap: wrap; }
}

@media (max-width: 600px) {
    .main-container { width: 100%; padding: 0 0.5rem; }
    .grid-layout { grid-template-columns: 1fr; }
}
