/* 
 * MiAuth Admin Panel Stylesheet
 * Style: Modern Gradient Cards (Design A)
 */

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

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background-color: #f1f5f9;
    color: #334155;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

/* 2. Container */
.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px;
}

/* 3. Navigation Bar — Dark Navy */
.nav-bar {
    background-color: #1e293b;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #fff;
}

.nav-link.active {
    color: #fff;
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.nav-dropdown-toggle:hover,
.nav-dropdown.open .nav-dropdown-toggle {
    color: #fff;
}

.nav-dropdown-toggle .arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.nav-dropdown.open .nav-dropdown-toggle .arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    min-width: 160px;
    padding: 6px 0;
    z-index: 200;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 10px 18px;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}

.nav-dropdown-menu a:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.nav-dropdown-menu .divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 0;
}

.nav-dropdown-menu a.danger {
    color: #dc2626;
}

.nav-dropdown-menu a.danger:hover {
    background: #fef2f2;
}

/* 4. Cards */
.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

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

.card-header h1,
.card-header h2,
.card-header h3 {
    font-weight: 600;
    color: #0f172a;
    margin: 0;
}

.card-header h1 { font-size: 1.5rem; }
.card-header h2 { font-size: 1.25rem; }
.card-header h3 { font-size: 1.1rem; }

.card-header .actions {
    display: flex;
    gap: 12px;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.actions form {
    display: inline-flex;
    margin: 0;
}

/* 5. Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    white-space: nowrap;
}

.btn:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-small, .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.btn-secondary:hover {
    background: #e2e8f0;
    box-shadow: none;
    transform: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    box-shadow: none;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* Button Ripple */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.btn:active::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0) translate(-50%, -50%);
        opacity: 0.5;
    }
    100% {
        transform: scale(40, 40) translate(-50%, -50%);
        opacity: 0;
    }
}

/* 6. Forms */
.form {
    max-width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #334155;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #0f172a;
    transition: all 0.2s ease;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-actions {
    margin-top: 32px;
    display: flex;
    gap: 12px;
}

.form-help {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 6px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 7. Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 24px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    padding: 12px 16px;
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    color: #64748b;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
}

.table tr:hover {
    background-color: #f8fafc;
}

.remark-cell {
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.5;
    min-width: 80px;
    color: #64748b;
}

/* 8. Badges */
.badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(5,150,105,0.1)); color: #059669; }
.badge-warning { background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(217,119,6,0.1)); color: #d97706; }
.badge-danger { background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(220,38,38,0.1)); color: #dc2626; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-info { background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(37,99,235,0.1)); color: #2563eb; }

/* 9. Alerts */
.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 14px;
}

.alert-success {
    background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(5,150,105,0.08));
    color: #059669;
    border: 1px solid rgba(16,185,129,0.2);
}

.alert-error, .alert-danger {
    background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(220,38,38,0.08));
    color: #dc2626;
    border: 1px solid rgba(239,68,68,0.2);
}

/* 10. Login Card */
.login-card {
    max-width: 400px;
    margin: 100px auto;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 32px;
    font-size: 24px;
    color: #0f172a;
}

.login-card .btn {
    width: 100%;
}

/* 11. Tabs */
.auth-tabs, .api-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0px;
}

.auth-tab, .api-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.auth-tab:hover, .api-tab:hover {
    color: #334155;
}

.auth-tab.active, .api-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.auth-content, .api-content {
    display: none;
}

.auth-content.active, .api-content.active {
    display: block;
}

/* 12. API Docs */
.api-docs {
    margin-top: 8px;
}

.api-section {
    margin-bottom: 32px;
}

.api-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #0f172a;
}

.api-url {
    display: block;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    margin: 12px 0;
    color: #0f172a;
    border: 1px solid #e2e8f0;
}

.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    white-space: pre;
    overflow-x: auto;
    line-height: 1.5;
}

/* 13. Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 32px;
}

.page-info, .pagination-info {
    font-size: 13px;
    color: #94a3b8;
}

/* 14. Filter Bar */
.filter-bar {
    margin-bottom: 20px;
}

.filter-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    white-space: nowrap;
}

.filter-select-wrap {
    position: relative;
}

.filter-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 36px 8px 14px;
    font-size: 13px;
    color: #334155;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    min-width: 180px;
    font-family: inherit;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filter-select:hover {
    border-color: #cbd5e1;
}

.filter-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 15. Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    display: block;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

.stat-card .stat-icon {
    float: right;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-card.accent-green .stat-icon { background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.15)); color: #059669; }
.stat-card.accent-blue .stat-icon { background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(37,99,235,0.15)); color: #2563eb; }
.stat-card.accent-orange .stat-icon { background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(217,119,6,0.15)); color: #d97706; }
.stat-card.accent-red .stat-icon { background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(220,38,38,0.15)); color: #dc2626; }
.stat-card.accent-purple .stat-icon { background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(124,58,237,0.15)); color: #7c3aed; }

/* 16. Dashboard Sections */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.dash-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.dash-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.dash-section-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #0f172a;
}

.expire-list {
    list-style: none;
}

.expire-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f8fafc;
    font-size: 13px;
}

.expire-item:last-child {
    border-bottom: none;
}

.expire-item .name {
    font-weight: 500;
    color: #0f172a;
}

.expire-item .date {
    color: #94a3b8;
}

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

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: #0f172a;
}

/* 18. Form Controls (standalone) */
.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #0f172a;
    transition: all 0.2s ease;
    outline: none;
}

.form-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

/* 18b. Client ID combo */
.client-id-combo {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.client-id-combo input {
    flex: 1;
    min-width: 0;
}

.client-id-combo select {
    flex: 0 0 180px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

/* 19. Helper text */
.helper-text, .help-text {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

/* 20. Filter form */
.filter-form {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    min-width: 200px;
    font-size: 14px;
    background: #fff;
}

/* 21. Bulk actions */
.bulk-actions {
    margin-bottom: 15px;
    padding: 15px;
    background-color: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.selection-info {
    margin-left: auto;
    font-weight: 600;
    color: #334155;
}

/* 22. Status badges for products */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-on {
    background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(5,150,105,0.1));
    color: #059669;
}

.status-off {
    background: linear-gradient(135deg, rgba(239,68,68,0.1), rgba(220,38,38,0.1));
    color: #dc2626;
}

/* 23. Empty message */
.empty-msg {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
    font-size: 14px;
}

/* 24. Responsive */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-bar {
        padding: 14px 16px;
        flex-direction: column;
        height: auto;
        gap: 12px;
        padding-top: 14px;
        padding-bottom: 14px;
    }
    
    .nav-links {
        width: 100%;
        justify-content: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .card-header .actions {
        width: 100%;
    }
    
    .card-header .actions .btn {
        flex: 1;
    }

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