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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

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

/* Navbar */
.navbar {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand {
    font-size: 20px;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    gap: 20px;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background 0.3s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 10px;
    font-size: 32px;
}

.subtitle {
    color: #7f8c8d;
    margin-bottom: 30px;
}

.login-form {
    text-align: left;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.login-footer {
    margin-top: 20px;
    font-size: 14px;
    color: #7f8c8d;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-error {
    background: #ffe6e6;
    color: #c0392b;
    border: 1px solid #e74c3c;
}

.alert-success {
    background: #e6ffe6;
    color: #27ae60;
    border: 1px solid #2ecc71;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 28px;
}

/* Cards */
.card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* Devices Grid */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.device-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s;
}

.device-card:hover {
    transform: translateY(-5px);
}

.device-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.device-stats {
    color: #7f8c8d;
    font-size: 14px;
}

.device-date {
    color: #95a5a6;
    font-size: 12px;
    margin-top: 5px;
}

/* Documents Grid */
.documents-grid {
    display: grid;
    gap: 15px;
}

.document-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.document-icon {
    font-size: 40px;
}

.document-info {
    flex: 1;
}

.document-info h3 {
    font-size: 16px;
    margin-bottom: 5px;
}

.document-meta {
    color: #7f8c8d;
    font-size: 14px;
}

.document-date {
    color: #95a5a6;
    font-size: 12px;
}

.document-actions {
    display: flex;
    gap: 10px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.empty-state p {
    margin-bottom: 20px;
    font-size: 18px;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
}

/* Spinner */
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 10px;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .page-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

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

    .document-card {
        flex-direction: column;
        text-align: center;
    }

    .document-actions {
        width: 100%;
        justify-content: center;
    }

    .btn-scan {
        width: 100%;
        margin: 5px 0 !important;
    }

    .camera-controls {
        padding: 10px;
    }
}

/* Prevent zoom on iOS */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    select,
    textarea,
    input {
        font-size: 16px !important;
    }
}

/* Full screen camera on mobile */
@media (max-width: 768px) {
    .camera-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 60vh;
        max-width: none;
        border-radius: 0;
        z-index: 100;
    }

    .camera-controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 101;
        margin: 0;
        border-radius: 0;
    }

    .scan-status {
        position: fixed;
        top: 60vh;
        left: 0;
        right: 0;
        z-index: 102;
        margin: 0;
        border-radius: 0;
    }

    .preview-grid {
        margin-top: 350px;
        padding: 10px;
    }
}
