/**
 * Stitch Easy Access - Main Stylesheet
 * Modern, clean design with turquoise/cyan theme
 */

/* ========== CSS Variables ========== */
:root {
    --primary-color: #4DD9D5;
    --primary-dark: #3BBFBB;
    --primary-light: #6FE4E1;
    --secondary-color: #1F2937;
    --text-dark: #1F2937;
    --text-gray: #6B7280;
    --text-light: #9CA3AF;
    --bg-light: #F9FAFB;
    --bg-gray: #F3F4F6;
    --border-color: #E5E7EB;
    --white: #FFFFFF;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* ========== Reset & Base Styles ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-dark);
    background: var(--bg-light);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-dark);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-gray);
}

/* ========== Layout ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
}

/* ========== Login/Register Page ========== */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-left {
    background: linear-gradient(135deg, #4DD9D5 0%, #3BBFBB 100%);
    color: white;
    padding: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    top: -200px;
    right: -200px;
}

.auth-left::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    bottom: -100px;
    left: -100px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
}

.auth-logo-icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.auth-logo h1 {
    font-size: 1.8rem;
    color: white;
    font-weight: 700;
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.auth-hero-title {
    font-size: 3rem;
    line-height: 1.1;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.auth-hero-text {
    font-size: 1.1rem;
    opacity: 0.95;
    line-height: 1.7;
    position: relative;
    z-index: 1;
    color: white;
}

.auth-features {
    display: grid;
    gap: 20px;
    margin-top: 40px;
    position: relative;
    z-index: 1;
}

.feature-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.3s ease;
}

.feature-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.feature-content h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: white;
}

.feature-content p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
    color: rgba(255, 255, 255, 0.95);
}

.auth-right {
    background: var(--bg-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.auth-form-container {
    background: white;
    padding: 50px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
}

.auth-form-header {
    margin-bottom: 32px;
}

.auth-welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.auth-form-title {
    font-size: 2rem;
    margin-bottom: 8px;
}

.auth-form-subtitle {
    color: var(--text-gray);
    font-size: 1rem;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--bg-light);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.1rem;
}

/* ========== Dashboard Layout ========== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 30px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.sidebar-logo {
    padding: 0 30px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4DD9D5, #3BBFBB);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    margin-bottom: 8px;
}

.sidebar-logo h2 {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.sidebar-logo-subtitle {
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    color: var(--text-gray);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

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

.nav-item-icon {
    font-size: 22px;
    width: 24px;
    text-align: center;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5px;
}

.nav-item.active .nav-item-icon {
    opacity: 1;
}

.nav-item.active .nav-item-icon svg {
    stroke-width: 2.5px;
}

.sidebar-user {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-user:hover {
    background: var(--bg-light);
}

.sidebar-user-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #4DD9D5, #3BBFBB);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-user-info h4 {
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.sidebar-user-info p {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 0;
}

.sidebar-user-logout {
    margin-left: auto;
    color: var(--text-light);
    font-size: 18px;
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 40px;
    background: var(--bg-light);
}

.page-header {
    margin-bottom: 40px;
}

.page-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.page-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.page-title {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-gray);
    font-size: 1.1rem;
}

/* ========== Cards ========== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

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

.stat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(77, 217, 213, 0.1), rgba(59, 191, 187, 0.1));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-gray);
    font-weight: 500;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
}

/* ========== QR Code Display ========== */
.qr-display {
    background: linear-gradient(135deg, #4DD9D5 0%, #3BBFBB 100%);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
}

.qr-display::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    top: -100px;
    right: -100px;
}

.qr-code-wrapper {
    background: white;
    padding: 30px;
    border-radius: var(--radius-md);
    display: inline-block;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-xl);
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code-image {
    max-width: 300px;
    width: 100%;
    display: block;
    transition: opacity 0.3s ease;
}

.qr-code-image[src=""],
.qr-code-image:not([src]) {
    opacity: 0;
}

.qr-code-wrapper::before {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 4px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
}

.qr-code-wrapper:has(.qr-code-image[src=""]):before,
.qr-code-wrapper:has(.qr-code-image:not([src])):before {
    opacity: 1;
}

.qr-instructions {
    margin-top: 24px;
    position: relative;
    z-index: 1;
}

.qr-instructions h3 {
    color: white;
    margin-bottom: 12px;
}

.qr-instructions p {
    color: rgba(255, 255, 255, 0.95);
}

/* ========== Status Badges ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
}

.status-in-building {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-out {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-gray);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== Tables ========== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

thead {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

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

tr:hover {
    background: var(--bg-light);
}

/* ========== Scanner Interface ========== */
.scanner-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-md);
}

.scanner-video-wrapper {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--secondary-color);
    margin-bottom: 24px;
}

#scanner-video {
    width: 100%;
    display: block;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.scanner-frame {
    width: 300px;
    height: 300px;
    border: 3px solid var(--primary-color);
    border-radius: var(--radius-md);
    position: relative;
}

.scanner-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid var(--primary-color);
}

.scanner-corner.top-left { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.scanner-corner.top-right { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.scanner-corner.bottom-left { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.scanner-corner.bottom-right { bottom: -2px; right: -2px; border-left: none; border-top: none; }

.scan-result {
    padding: 20px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    text-align: center;
    font-weight: 600;
}

.scan-result.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 2px solid var(--success);
}

.scan-result.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 2px solid var(--error);
}

/* ========== Mobile Menu Button ========== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    backdrop-filter: blur(4px);
}

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

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-left {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 9999;
    }

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

    .main-content {
        margin-left: 0;
        padding-top: 80px;
    }

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

@media (max-width: 768px) {
    .auth-form-container {
        padding: 30px;
    }

    .page-title {
        font-size: 2rem;
    }

    .main-content {
        padding: 20px;
    }
}

/* ========== Modals ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-gray);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--bg-light);
    color: var(--text-dark);
}

/* ========== Utility Classes ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* ========== Loading Animation ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

.btn .loading {
    margin-left: 8px;
}

/* ========== Alerts ========== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.alert-info {
    background: rgba(77, 217, 213, 0.1);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.demo-credentials {
    background: rgba(77, 217, 213, 0.1);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--text-gray);
}

.demo-credentials strong {
    color: var(--primary-color);
}
