@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    --bg-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;

    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;

    --border-color: #e5e7eb;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* Base Elements */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.2;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Login Page specific */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top left, #0f172a 0%, #020617 100%);
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
    top: -50px;
    left: -50px;
    border-radius: 50%;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
    border-radius: 50%;
    pointer-events: none;
}

.login-card {
    background: var(--surface-color);
    padding: 2.5rem 2rem;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    animation: slideUp 0.4s ease-out forwards;
    position: relative;
    z-index: 10;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    background-color: var(--surface-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(14, 165, 233, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background-color: #fef2f2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

/* Dashboard Specifics */
.header-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.header-title-group h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-title-group p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background-color: #fef2f2;
    color: var(--danger-color);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #fee2e2;
}

.btn-logout:hover {
    background-color: var(--danger-color);
    color: #ffffff;
    text-decoration: none;
}

/* Cards & Sections */
.card-section {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Form Grid */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}

.grid-full-width {
    grid-column: 1 / -1;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-in_progress {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-done {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-cancelled {
    background-color: #fee2e2;
    color: #991b1b;
}

.priority-high {
    color: var(--danger-color);
    font-weight: 700;
}

.priority-medium {
    color: var(--warning-color);
    font-weight: 600;
}

.priority-low {
    color: var(--success-color);
    font-weight: 600;
}

/* Responsive Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 0.9rem;
}

.styled-table th,
.styled-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.styled-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
}

.styled-table tbody tr {
    transition: background-color 0.2s ease;
}

.styled-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Row Highlights by Status */
.styled-table tr.row-new td:first-child {
    border-left: 4px solid var(--primary-color);
}

.styled-table tr.row-in_progress td:first-child {
    border-left: 4px solid var(--warning-color);
}

.styled-table tr.row-done td:first-child {
    border-left: 4px solid var(--success-color);
}

.styled-table tr.row-cancelled td:first-child {
    border-left: 4px solid var(--danger-color);
}

/* Table Actions */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit {
    background-color: #eff6ff;
    color: var(--primary-color);
}

.btn-edit:hover {
    background-color: #dbeafe;
    color: var(--primary-hover);
    text-decoration: none;
}

.btn-delete {
    background-color: #fef2f2;
    color: var(--danger-color);
}

.btn-delete:hover {
    background-color: #fee2e2;
    color: #b91c1c;
}

/* Installer Cards */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.installer-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.installer-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.installer-card.card-new {
    border-top: 4px solid var(--primary-color);
}

.installer-card.card-in_progress {
    border-top: 4px solid var(--warning-color);
}

.installer-card.card-done {
    border-top: 4px solid var(--success-color);
}

.installer-card.card-cancelled {
    border-top: 4px solid var(--danger-color);
}

.card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.card-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.card-id {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 500;
}

.card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-footer {
    padding: 1.25rem;
    background-color: #f9fafb;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

/* Stats Row */
.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--surface-color);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 140px;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .grid-form {
        grid-template-columns: 1fr;
    }

    .stats-row {
        gap: 0.5rem;
    }

    .stat-box {
        padding: 0.75rem 1rem;
        min-width: calc(50% - 0.5rem);
    }
}

/* --- Control Panel Dashboard (Admin) --- */
.cp-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.cp-card {
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cp-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.cp-icon {
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.cp-info {
    display: flex;
    flex-direction: column;
}

.cp-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cp-label {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.95;
    letter-spacing: 0.05em;
}

.cp-installation {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

.cp-dismantling {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
}

.cp-damage {
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
}

@media (max-width: 600px) {
    .cp-dashboard {
        grid-template-columns: 1fr;
    }
}

/* Dark Mode Login Page Overrides */
.login-page .login-card {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-page .login-header p {
    color: #94a3b8;
}

.login-page label {
    color: #cbd5e1;
}

.login-page .form-input {
    color: #f8fafc;
    background-color: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-page .form-input::placeholder {
    color: #64748b;
}

.login-page .form-input:focus {
    background-color: rgba(15, 23, 42, 0.85);
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
}

/* Fiber Optic Neon Background */
.fiber-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.fiber-line {
    position: absolute;
    height: 1.5px;
    width: 150%;
    left: -25%;
    background: linear-gradient(90deg, 
        rgba(6, 182, 212, 0) 0%, 
        rgba(6, 182, 212, 0.8) 25%, 
        rgba(236, 72, 153, 0.8) 50%, 
        rgba(99, 102, 241, 0.8) 75%, 
        rgba(6, 182, 212, 0) 100%
    );
    background-size: 200% 100%;
    filter: drop-shadow(0 0 3px rgba(6, 182, 212, 0.8)) drop-shadow(0 0 8px rgba(236, 72, 153, 0.6));
    opacity: 0.25;
}

.fiber-1 {
    top: 15%;
    transform: rotate(-12deg);
    animation: fiberFlow 7s linear infinite;
}

.fiber-2 {
    top: 40%;
    transform: rotate(-8deg);
    animation: fiberFlow 11s linear infinite reverse;
}

.fiber-3 {
    top: 65%;
    transform: rotate(-15deg);
    animation: fiberFlow 9s linear infinite;
}

.fiber-4 {
    top: 85%;
    transform: rotate(-10deg);
    animation: fiberFlow 13s linear infinite reverse;
}

@keyframes fiberFlow {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}