body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

.footer {
    margin-top: auto;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    margin: 1rem;
}

@media (max-width: 576px) {
    .login-card {
        padding: 1.5rem;
        margin: 0.5rem;
        border-radius: 0.5rem;
    }

    .login-card h2 {
        font-size: 1.5rem;
    }

    .login-card .bi-shield-lock {
        font-size: 2.5rem !important;
    }
}

@media (max-width: 400px) {
    .login-card {
        padding: 1rem;
        border-radius: 0.25rem;
    }

    .login-card h2 {
        font-size: 1.25rem;
    }
}

.card {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: none;
    margin-bottom: 1rem;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.api-key-display {
    font-family: 'Courier New', monospace;
    background-color: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

.table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.navbar-brand {
    font-weight: 600;
}

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Touch-friendly design */
.btn, .form-control, .form-select {
    min-height: 44px;
}

.btn-sm {
    min-height: 38px;
}

/* Mobile-friendly navbar */
.navbar-nav .nav-link {
    padding: 0.75rem 1rem;
}

@media (max-width: 991px) {
    .navbar-nav .nav-link {
        padding: 0.875rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }

    /* User info stacked on mobile */
    .navbar .d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100%;
        padding: 1rem;
        gap: 0.75rem;
    }

    .navbar .d-flex .btn {
        width: 100%;
    }
}

/* Responsive improvements */
@media (max-width: 1200px) {
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 768px) {
    /* Stack cards vertically on mobile */
    .col-md-3, .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Larger headings for readability */
    h1 {
        font-size: 1.75rem;
    }

    .card h2 {
        font-size: 1.75rem;
    }

    .card h6 {
        font-size: 0.9rem;
    }

    /* Responsive navbar */
    .navbar-brand {
        font-size: 1.1rem;
    }

    /* Modal full width on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-body {
        padding: 1.25rem;
    }

    /* Convert table to card view on mobile */
    .table-responsive table {
        border: 0;
    }

    .table-responsive table thead {
        display: none;
    }

    .table-responsive table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        padding: 1rem;
    }

    .table-responsive table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.75rem 0;
        border: 0;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
        min-height: 44px;
    }

    .table-responsive table tbody td:last-child {
        border-bottom: 0;
    }

    .table-responsive table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        flex: 0 0 45%;
        padding-right: 1rem;
        word-wrap: break-word;
    }

    /* Actions column - stack buttons vertically */
    .table-responsive table tbody td:last-child {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .table-responsive table tbody td:last-child::before {
        margin-bottom: 0.5rem;
    }

    .table-responsive table tbody td .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .table-responsive table tbody td .btn {
        font-size: 0.9rem;
        padding: 0.625rem 1rem;
        width: 100%;
        justify-content: center;
        white-space: nowrap;
    }

    /* API key display full width on mobile */
    .api-key-display {
        font-size: 0.85rem;
        word-break: break-all;
        display: block;
        width: 100%;
    }

    /* Badge styling */
    .badge {
        font-size: 0.85rem;
        padding: 0.4em 0.7em;
    }
}

@media (max-width: 576px) {
    /* Even more compact on small phones */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Touch-friendly buttons */
    .btn {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
        min-height: 48px;
    }

    .btn-sm {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        min-height: 42px;
    }

    /* Form controls */
    .form-control, .form-select {
        font-size: 1rem;
        padding: 0.75rem;
        min-height: 48px;
    }

    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
        font-weight: 600;
    }

    /* Card view adjustments for small screens */
    .table-responsive table tbody tr {
        padding: 0.875rem;
    }

    .table-responsive table tbody td {
        font-size: 0.9rem;
        padding: 0.625rem 0;
    }

    .table-responsive table tbody td::before {
        font-size: 0.9rem;
        flex: 0 0 40%;
    }

    /* Card spacing */
    .card {
        margin-bottom: 1.25rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    /* Stats cards icon size */
    .card-body i[style*="font-size: 3rem"] {
        font-size: 2.5rem !important;
    }
}
