@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #176b3a;
    --primary-dark: #0e512b;
    --primary-light: #eaf5ee;

    --sidebar: #0d4028;
    --sidebar-hover: rgba(255,255,255,.07);
    --sidebar-active: rgba(255,255,255,.12);

    --background: #f5f7f6;
    --surface: #ffffff;

    --text: #17221b;
    --text-secondary: #66736c;
    --muted: #929e97;

    --border: #dde5e0;
    --border-soft: #edf1ee;

    --danger: #c93636;
    --danger-light: #fff1f1;
    --success: #198754;
    --success-light: #eaf7ef;
    --warning: #e3a008;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;

    --shadow: 0 10px 35px rgba(25, 55, 39, 0.08);
}

/* =====================================================
   RESET / BASE
===================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', Tahoma, Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

button {
    cursor: pointer;
}

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

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
}

.login-cover {
    min-height: 100vh;
    padding: 55px 65px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background:
        linear-gradient(
            135deg,
            rgba(8, 67, 36, 0.96),
            rgba(20, 116, 62, 0.90)
        ),
        url('../images/login-bg.jpg');
    background-size: cover;
    background-position: center;
}

.login-cover::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: rgba(255,255,255,.05);
    left: -150px;
    bottom: -180px;
}

.brand {
    position: relative;
    z-index: 2;
    color: white;
}

.brand-name {
    font-size: 27px;
    font-weight: 800;
    letter-spacing: 1px;
}

.brand-subtitle {
    font-size: 12px;
    margin-top: 2px;
    color: rgba(255,255,255,.7);
}

.cover-content {
    color: white;
    position: relative;
    z-index: 2;
    max-width: 600px;
}

.cover-content .small-title {
    display: inline-block;
    padding: 7px 13px;
    border: 1px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.08);
    border-radius: 30px;
    font-size: 12px;
    margin-bottom: 22px;
}

.cover-content h1 {
    font-size: 46px;
    line-height: 1.45;
    font-weight: 800;
    margin-bottom: 18px;
}

.cover-content p {
    font-size: 16px;
    line-height: 2;
    color: rgba(255,255,255,.78);
}

.cover-footer {
    position: relative;
    z-index: 2;
    color: rgba(255,255,255,.55);
    font-size: 12px;
}

.login-area {
    background: var(--surface);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
}

.login-box {
    width: 100%;
    max-width: 430px;
}

.mobile-logo {
    display: none;
    margin-bottom: 35px;
    color: var(--primary);
    font-weight: 800;
    font-size: 24px;
}

.login-box h2 {
    font-size: 31px;
    margin-bottom: 8px;
}

.login-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.9;
    margin-bottom: 32px;
}

.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 3px 0 24px;
}

.remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.remember input {
    accent-color: var(--primary);
}

.btn-primary {
    width: 100%;
    height: 52px;
    border: 0;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.login-security {
    text-align: center;
    color: #9aa59f;
    font-size: 11px;
    margin-top: 25px;
}

/* =====================================================
   APPLICATION LAYOUT
===================================================== */

.app-body {
    background: var(--background);
}

.app-layout {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 265px;
    background: var(--sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-brand {
    min-height: 90px;
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    background: white;
    color: var(--primary);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
}

.sidebar-brand strong {
    display: block;
    font-size: 14px;
    letter-spacing: .5px;
}

.sidebar-brand span {
    display: block;
    margin-top: 2px;
    color: rgba(255,255,255,.55);
    font-size: 9px;
    text-transform: uppercase;
}

.sidebar-nav {
    padding: 18px 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-label {
    padding: 14px 13px 7px;
    color: rgba(255,255,255,.38);
    font-size: 10px;
    font-weight: 700;
}

.nav-item {
    height: 47px;
    padding: 0 14px;
    margin: 3px 0;
    border-radius: 10px;
    color: rgba(255,255,255,.72);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    transition: .2s;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
    font-weight: 700;
}

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 17px;
}

.sidebar-bottom {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.sidebar-user .user-avatar {
    background: rgba(255,255,255,.13);
    color: white;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-info strong {
    display: block;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info span {
    display: block;
    color: rgba(255,255,255,.48);
    font-size: 10px;
    margin-top: 2px;
}

.logout-link {
    display: block;
    margin-top: 13px;
    padding: 9px;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    color: rgba(255,255,255,.65);
    background: rgba(255,255,255,.05);
    font-size: 11px;
}

.logout-link:hover {
    color: white;
    background: rgba(255,255,255,.09);
}

.main-area {
    margin-right: 265px;
    min-height: 100vh;
}

.topbar {
    min-height: 90px;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 500;
}

.page-title {
    font-size: 20px;
    font-weight: 800;
}

.page-subtitle {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 11px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.today-date {
    color: var(--text-secondary);
    font-size: 11px;
}

.notification-btn {
    width: 39px;
    height: 39px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
}

.topbar-profile {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-right: 15px;
    border-right: 1px solid var(--border);
}

.topbar-profile strong {
    display: block;
    font-size: 11px;
}

.topbar-profile span {
    display: block;
    color: var(--text-secondary);
    font-size: 9px;
    margin-top: 2px;
}

.content {
    padding: 30px 32px 50px;
}

/* =====================================================
   COMMON COMPONENTS
===================================================== */

.content-toolbar,
.form-page-header,
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.content-toolbar {
    margin-bottom: 22px;
}

.content-toolbar h2,
.form-page-header h2 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.content-toolbar p,
.form-page-header p {
    color: var(--text-secondary);
    font-size: 11px;
}

.btn-action,
.btn-secondary {
    min-height: 42px;
    padding: 0 17px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: .2s ease;
}

.btn-action {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
}

.btn-action:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f8faf8;
}

.alert-success,
.alert-danger {
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 11px;
}

.alert-success {
    background: var(--success-light);
    color: #176b3a;
    border: 1px solid #cdebd9;
}

.alert-danger {
    background: var(--danger-light);
    color: #b42318;
    border: 1px solid #ffd7d7;
}

.panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-header {
    min-height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 14px;
}

.panel-body {
    padding: 20px;
}

.empty-state {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #98a49d;
    text-align: center;
    padding: 25px;
}

.empty-state strong {
    color: #657169;
    font-size: 13px;
    margin-bottom: 5px;
}

.empty-state span {
    font-size: 11px;
}

/* =====================================================
   FORMS
===================================================== */

.form-group {
    margin-bottom: 19px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    height: 52px;
    border: 1px solid var(--border);
    background: #fbfcfb;
    border-radius: var(--radius);
    padding: 0 15px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: .2s ease;
}

.form-control:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(23,107,58,.09);
}

.form-control::placeholder {
    color: #adb7b1;
}

.form-page {
    max-width: 1100px;
}

.form-page-header {
    margin-bottom: 22px;
}

.form-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-section-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--primary);
    padding-bottom: 10px;
    margin: 8px 0 18px;
    border-bottom: 1px solid var(--border);
}

.form-section-title:not(:first-child) {
    margin-top: 20px;
}

.required {
    color: var(--danger);
}

.file-control {
    width: 100%;
    min-height: 52px;
    border: 1px dashed #cdd9d1;
    background: #fafcfa;
    border-radius: var(--radius);
    padding: 12px;
    font-family: inherit;
}

.field-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 9px;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 20px;
    margin-top: 5px;
    border-top: 1px solid var(--border);
}

/* =====================================================
   DASHBOARD
===================================================== */

.welcome-card {
    padding: 27px 30px;
    background: linear-gradient(110deg, #105d35, #17844b);
    border-radius: var(--radius-lg);
    color: white;
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
}

.welcome-card::after {
    content: "";
    width: 230px;
    height: 230px;
    position: absolute;
    left: -45px;
    top: -80px;
    border: 35px solid rgba(255,255,255,.05);
    border-radius: 50%;
}

.welcome-card h2 {
    font-size: 21px;
    margin-bottom: 6px;
}

.welcome-card p {
    color: rgba(255,255,255,.72);
    font-size: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 17px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}

.stat-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-value {
    margin-top: 12px;
    font-size: 26px;
    font-weight: 800;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
}

/* =====================================================
   SEARCH
===================================================== */

.search-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 18px;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-form .form-control {
    flex: 1;
}

/* =====================================================
   TABLES
===================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.data-table thead {
    background: #fafbfa;
}

.data-table th {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.data-table td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 11px;
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: #fbfcfb;
}

.table-empty {
    padding: 50px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.table-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-user .user-avatar {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 12px;
}

.table-user strong {
    font-size: 11px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 30px;
    font-size: 9px;
    font-weight: 700;
}

.status-badge.success {
    background: var(--success-light);
    color: #167342;
}

.status-badge.danger {
    background: var(--danger-light);
    color: #b42318;
}

.table-action {
    display: inline-flex;
    padding: 7px 13px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 8px;
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
}

.table-action:hover {
    background: #dcefe3;
}

.ltr-value {
    direction: ltr;
    text-align: right;
}

/* =====================================================
   CONTRACTORS
===================================================== */

.contractor-name {
    font-size: 12px;
    font-weight: 700;
}

.profile-header {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.profile-main {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-avatar {
    width: 58px;
    height: 58px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 800;
}

.profile-label {
    display: block;
    color: var(--primary);
    font-size: 9px;
    font-weight: 700;
    margin-bottom: 3px;
}

.profile-main h2 {
    font-size: 18px;
}

.profile-main p {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 3px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.detail-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.detail-item span,
.document-card span {
    display: block;
    color: var(--text-secondary);
    font-size: 9px;
    margin-bottom: 6px;
}

.detail-item strong,
.document-card strong {
    font-size: 11px;
}

.documents-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.document-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.document-link {
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.section-heading {
    margin: 25px 0 12px;
}

.section-heading h3 {
    font-size: 15px;
}

.section-heading p {
    color: var(--text-secondary);
    font-size: 10px;
    margin-top: 3px;
}

/* =====================================================
   RESPONSIVE
===================================================== */

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .details-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .login-page {
        display: block;
    }

    .login-cover {
        display: none;
    }

    .login-area {
        min-height: 100vh;
        padding: 25px;
    }

    .mobile-logo {
        display: block;
    }

    .sidebar {
        width: 220px;
    }

    .main-area {
        margin-right: 220px;
    }

    .topbar {
        padding: 0 20px;
    }

    .content {
        padding: 22px 20px 40px;
    }
}

@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nav-label {
        grid-column: 1 / -1;
    }

    .sidebar-bottom {
        display: none;
    }

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

    .topbar {
        position: static;
        min-height: auto;
        padding: 18px;
        gap: 15px;
        align-items: flex-start;
    }

    .topbar-actions {
        gap: 8px;
    }

    .today-date,
    .topbar-profile > div:last-child {
        display: none;
    }

    .content {
        padding: 18px;
    }

    .stats-grid,
    .form-grid,
    .form-grid-3,
    .details-grid,
    .documents-grid {
        grid-template-columns: 1fr;
    }

    .content-toolbar,
    .form-page-header,
    .profile-header,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-action,
    .btn-secondary {
        width: 100%;
    }
}
/* =====================================================
   PRODUCTION WORKFLOW
===================================================== */

.workflow-list {
    padding: 10px 22px;
}

.workflow-item {
    position: relative;
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 15px;
    min-height: 88px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
}

.workflow-item:last-child {
    border-bottom: 0;
}

.workflow-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    background: #f2f5f3;
    color: var(--text-secondary);

    font-size: 12px;
    font-weight: 800;
}

.workflow-item.current .workflow-number {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 5px rgba(23,107,58,.10);
}

.workflow-item.completed .workflow-number {
    background: var(--success-light);
    color: var(--success);
}

.workflow-item.locked {
    opacity: .55;
}

.workflow-title {
    font-size: 13px;
    font-weight: 800;
}

.workflow-description {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 10px;
}

.workflow-meta {
    margin-top: 5px;
    color: var(--success);
    font-size: 9px;
}

.workflow-action {
    min-width: 90px;
    text-align: left;
}

@media (max-width: 760px) {

    .workflow-item {
        grid-template-columns: 42px 1fr;
    }

    .workflow-action {
        grid-column: 2;
        text-align: right;
    }
}