/* 
 * SAMRIFA Scraping System
 * Sketch Style - Green Theme
 * Font: Quicksand
 */

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

:root {
    /* Primary Green Palette */
    --primary-50: #f0fdf4;
    --primary-100: #dcfce7;
    --primary-200: #bbf7d0;
    --primary-300: #86efac;
    --primary-400: #4ade80;
    --primary-500: #22c55e;
    --primary-600: #16a34a;
    --primary-700: #15803d;
    --primary-800: #166534;
    --primary-900: #14532d;

    /* Neutral */
    --neutral-50: #fafafa;
    --neutral-100: #f5f5f5;
    --neutral-200: #e5e5e5;
    --neutral-300: #d4d4d4;
    --neutral-400: #a3a3a3;
    --neutral-500: #737373;
    --neutral-600: #525252;
    --neutral-700: #404040;
    --neutral-800: #262626;
    --neutral-900: #171717;

    /* Status Colors */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Sketch Style */
    --border-width: 2px;
    --border-color: var(--primary-700);
    --border-sketch: var(--border-width) solid var(--border-color);
    --shadow-sketch: 4px 4px 0 rgba(21, 128, 61, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Quicksand', sans-serif;
    background-color: var(--neutral-100);
    color: var(--neutral-700);
    line-height: 1.6;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary-600) 0%, var(--primary-700) 100%);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    border-right: var(--border-sketch);
    box-shadow: var(--shadow-sketch);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.sidebar-logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateX(4px);
}

.sidebar-nav a.active {
    background: white;
    color: var(--primary-700);
    border-color: var(--primary-800);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

.sidebar-nav svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px dashed rgba(255, 255, 255, 0.2);
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    padding-left: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 3rem;
    /* Increased padding for better breathability */
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--primary-600);
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    z-index: 1001;
    border-bottom: var(--border-sketch);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-toggle {
    background: white;
    border: 2px solid var(--primary-800);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-800);
}

.mobile-toggle svg {
    width: 24px;
    height: 24px;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-800);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--neutral-500);
    font-size: 0.95rem;
}

/* Cards - Sketch Style */
.card {
    background: white;
    border: var(--border-sketch);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sketch);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 rgba(21, 128, 61, 0.2);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 2px dashed var(--primary-200);
    background: var(--primary-50);
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-800);
}

.card-body {
    padding: 2rem;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border: var(--border-sketch);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sketch);
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 rgba(21, 128, 61, 0.2);
}

.stat-card.primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    border-color: var(--primary-700);
}

.stat-card.primary .stat-label,
.stat-card.primary .stat-value {
    color: white;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    background: var(--primary-100);
    border: 2px solid var(--primary-300);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    color: var(--primary-600);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-800);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--neutral-500);
    margin-top: 0.5rem;
    font-weight: 500;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    font-weight: 600;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* Buttons - Sketch Style */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1.25rem;
    /* Remove vertical padding to let height control centering */
    margin: 0;
    /* Clear browser defaults */
    font-family: 'Quicksand', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    height: 40px;
    border: var(--border-sketch);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 3px 3px 0 rgba(21, 128, 61, 0.15);
    box-sizing: border-box;
    vertical-align: middle;
}

.btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 rgba(21, 128, 61, 0.2);
}

.btn:active {
    transform: translate(0, 0);
    box-shadow: 2px 2px 0 rgba(21, 128, 61, 0.15);
}

/* Browser Specific Resets for Buttons */
button.btn::-moz-focus-inner {
    border: 0;
    padding: 0;
}

button.btn {
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: white;
    border-color: var(--primary-700);
}

.btn-secondary {
    background: white;
    color: var(--primary-700);
    border-color: var(--primary-600);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: #b91c1c;
}

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

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* Form Elements - Sketch Style */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--neutral-700);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.95rem;
    border: var(--border-sketch);
    border-radius: var(--radius-sm);
    background: white;
    transition: all 0.2s ease;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.05);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2), inset 2px 2px 4px rgba(0, 0, 0, 0.05);
}

.form-control::placeholder {
    color: var(--neutral-400);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* Table - Sketch Style */
.table-container {
    overflow-x: auto;
    border: var(--border-sketch);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sketch);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: var(--primary-50);
}

th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary-800);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary-300);
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px dashed var(--neutral-200);
    font-size: 0.9rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: var(--primary-50);
}

/* Badge - Sketch Style */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50px;
    border: 2px solid;
}

.badge-success {
    background: var(--primary-100);
    color: var(--primary-700);
    border-color: var(--primary-400);
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
    border-color: #fbbf24;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #f87171;
}

.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #60a5fa;
}

.badge-secondary {
    background: var(--neutral-100);
    color: var(--neutral-600);
    border-color: var(--neutral-300);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border: var(--border-sketch);
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sketch);
}

.alert-success {
    background: var(--primary-100);
    border-color: var(--primary-500);
    color: var(--primary-800);
}

.alert-error {
    background: #fee2e2;
    border-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background: #fef3c7;
    border-color: var(--warning);
    color: #92400e;
}

/* Progress Bar */
.progress {
    height: 12px;
    background: var(--neutral-200);
    border-radius: 50px;
    overflow: hidden;
    border: 2px solid var(--neutral-300);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-400) 0%, var(--primary-500) 100%);
    border-radius: 50px;
    transition: width 0.3s ease;
}

/* Grid Layout */
.grid {
    display: grid;
    gap: 1.5rem;
}

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

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

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

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        top: 60px;
        height: calc(100vh - 60px);
        width: 280px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 5.5rem 1.5rem 2rem;
        /* Account for mobile header */
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

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

/* Flex utilities */
.flex {
    display: flex;
}

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

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

/* Spacing utilities */
.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mt-4 {
    margin-top: 2rem;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-success {
    color: var(--success);
}

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

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--neutral-500);
}

.text-primary {
    color: var(--primary-600);
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

/* Better Pagination - Sketch Style */
nav[role="navigation"] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2.5rem;
    padding: 1.25rem;
    background: var(--primary-50);
    border: 2px dashed var(--primary-200);
    border-radius: var(--radius);
}

nav[role="navigation"] .flex-1,
nav[role="navigation"] .hidden {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* "Showing X to Y of Z" text */
nav[role="navigation"] p {
    font-size: 0.85rem !important;
    color: var(--neutral-600) !important;
    font-weight: 500 !important;
    margin: 0 !important;
}

nav[role="navigation"] p span {
    font-weight: 700 !important;
    color: var(--primary-700) !important;
}

/* Page Numbers Container */
nav[role="navigation"] .inline-flex {
    display: flex !important;
    gap: 6px !important;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
}

/* Individual Links/Buttons */
nav[role="navigation"] a,
nav[role="navigation"] span[aria-current="page"]>span,
nav[role="navigation"] span[aria-disabled="true"]>span {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 0.75rem !important;
    background: white !important;
    border: 2px solid var(--primary-300) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--primary-700) !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    box-shadow: 3px 3px 0 rgba(21, 128, 61, 0.1) !important;
}

/* Hover State */
nav[role="navigation"] a:hover {
    background: var(--primary-100) !important;
    border-color: var(--primary-600) !important;
    transform: translate(-1px, -1px) !important;
    box-shadow: 4px 4px 0 rgba(21, 128, 61, 0.15) !important;
}

/* Active State */
nav[role="navigation"] span[aria-current="page"]>span {
    background: var(--primary-600) !important;
    color: white !important;
    border-color: var(--primary-800) !important;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Disabled State */
nav[role="navigation"] span[aria-disabled="true"]>span {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: var(--neutral-50) !important;
    border-color: var(--neutral-200) !important;
    color: var(--neutral-400) !important;
    box-shadow: none !important;
}

/* SVG Icons fixing */
nav[role="navigation"] svg {
    width: 20px !important;
    height: 20px !important;
    display: inline-block !important;
    vertical-align: middle !important;
}


/* Table Polish */
td {
    padding: 1.25rem 1rem;
    font-size: 0.95rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--neutral-200);
}

tr:hover td {
    background-color: var(--primary-50);
}


.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--primary-700);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--neutral-500);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--neutral-300);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--neutral-600);
    margin-bottom: 0.5rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border: var(--border-sketch);
    border-radius: var(--radius);
    box-shadow: 8px 8px 0 rgba(21, 128, 61, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-backdrop.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 2px dashed var(--primary-200);
    background: var(--primary-50);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 2px dashed var(--primary-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Scroll to top */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--primary-600);
    border: 2px solid var(--primary-700);
    border-radius: var(--radius-sm);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sketch);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    transform: translateY(-4px);
}

/* Timeline/Milestone */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-200);
    border-radius: 3px;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--neutral-300);
}

.timeline-item.completed::before {
    background: var(--primary-500);
    border-color: var(--primary-600);
}

.timeline-item.in-progress::before {
    background: var(--warning);
    border-color: #d97706;
}

.timeline-title {
    font-weight: 600;
    color: var(--neutral-700);
}

.timeline-item.completed .timeline-title {
    color: var(--primary-700);
}

.timeline-desc {
    font-size: 0.85rem;
    color: var(--neutral-500);
    margin-top: 0.25rem;
}