@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #070913;
    --card-bg: rgba(18, 22, 41, 0.6);
    --border-light: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-color: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --status-started: #10b981;
    --status-started-glow: rgba(16, 185, 129, 0.3);
    --status-stopped: #ef4444;
    --status-stopped-glow: rgba(239, 68, 68, 0.3);
    --status-warning: #f59e0b;
    --status-warning-glow: rgba(245, 158, 11, 0.3);
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 45%);
    background-attachment: fixed;
}

/* Glassmorphism containers */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

/* Master Layout */
header {
    width: 100%;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    background: rgba(7, 9, 19, 0.8);
    backdrop-filter: blur(12px);
    z-index: 100;
    position: sticky;
    top: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--accent-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 0 15px var(--accent-glow);
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.25s ease;
    padding: 6px 12px;
    border-radius: 6px;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-badge-admin {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.logout-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

main {
    flex: 1;
    padding: 2.5rem 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Card components */
.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Buttons */
.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-started {
    background: rgba(16, 185, 129, 0.1);
    color: var(--status-started);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.status-started::before {
    background: var(--status-started);
    box-shadow: 0 0 8px var(--status-started);
}

.status-stopped {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-stopped);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.status-stopped::before {
    background: var(--status-stopped);
    box-shadow: 0 0 8px var(--status-stopped);
}

.status-transition {
    background: rgba(245, 158, 11, 0.1);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
    animation: pulse 1.5s infinite;
}
.status-transition::before {
    background: var(--status-warning);
    box-shadow: 0 0 8px var(--status-warning);
}

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

/* Action Controls */
.action-btn-group {
    display: flex;
    gap: 8px;
}

.action-btn {
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
}

.action-start {
    background: rgba(16, 185, 129, 0.15);
    color: var(--status-started);
    border: 1px solid rgba(16, 185, 129, 0.25);
}
.action-start:hover:not(:disabled) {
    background: var(--status-started);
    color: #fff;
    box-shadow: 0 0 10px var(--status-started-glow);
}

.action-stop {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-stopped);
    border: 1px solid rgba(239, 68, 68, 0.25);
}
.action-stop:hover:not(:disabled) {
    background: var(--status-stopped);
    color: #fff;
    box-shadow: 0 0 10px var(--status-stopped-glow);
}

.action-recycle {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.25);
}
.action-recycle:hover:not(:disabled) {
    background: var(--status-warning);
    color: #fff;
    box-shadow: 0 0 10px var(--status-warning-glow);
}

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

/* Dashboard Section Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Table layout */
.modern-table-container {
    overflow-x: auto;
    width: 100%;
}

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

.modern-table th {
    padding: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.modern-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.95rem;
}

.modern-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Confirm Action Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 14, 0.85);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.confirm-modal {
    width: 90%;
    max-width: 480px;
    padding: 2rem;
    text-align: center;
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 1.75rem;
}

.modal-icon-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Log view filters layout */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 2rem;
}

.filter-input {
    min-width: 160px;
    flex: 1;
}

/* Success/Error alert toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: #fff;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
}

.toast-success {
    background: var(--status-started);
    border-left: 5px solid #059669;
}

.toast-error {
    background: var(--status-stopped);
    border-left: 5px solid #dc2626;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Login box styles */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

/* Responsive adjustments for page headers and actions */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Bootstrap Dropdown Custom styling to match glass theme */
.header-dropdown-btn {
    background: rgba(99, 102, 241, 0.1) !important;
    border: 1px solid rgba(99, 102, 241, 0.2) !important;
    color: var(--text-primary) !important;
    border-radius: 20px !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    padding: 6px 16px !important;
    transition: all 0.25s ease !important;
    display: inline-flex !important;
    align-items: center !important;
}

.header-dropdown-btn:hover, 
.header-dropdown-btn:focus, 
.header-dropdown-btn[aria-expanded="true"] {
    background: rgba(99, 102, 241, 0.2) !important;
    border-color: rgba(99, 102, 241, 0.4) !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2) !important;
    color: #fff !important;
}

.header-profile-icon {
    margin-right: 6px;
}

.dropdown-menu-dark {
    background: rgba(18, 22, 41, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid var(--border-light) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    border-radius: 12px !important;
    padding: 8px !important;
    margin-top: 8px !important;
}

.dropdown-item {
    border-radius: 6px !important;
    font-size: 0.9rem !important;
    padding: 8px 16px !important;
    color: var(--text-secondary) !important;
    transition: all 0.2s ease !important;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
}

.dropdown-item.active {
    background: var(--accent-gradient) !important;
    color: #fff !important;
}

@media (max-width: 768px) {
    /* Header stays compact and horizontal */
    header {
        padding: 0.75rem 1rem;
    }
    
    .logo-text {
        font-size: 1.25rem;
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .header-actions {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 0.75rem;
    }
    
    .header-actions button,
    .header-actions .btn-secondary {
        width: auto;
        justify-content: center;
    }

    .refresh-text {
        display: none;
    }

    .header-username {
        display: none;
    }

    .header-profile-icon {
        margin-right: 0;
    }
    
    /* Toast notifications on mobile */
    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        width: 100%;
    }
}

/* Responsive tables to prevent horizontal scrolling on mobile viewports */
@media (max-width: 768px) {
    .modern-table, 
    .modern-table thead, 
    .modern-table tbody, 
    .modern-table th, 
    .modern-table td, 
    .modern-table tr { 
        display: block; 
    }
    
    .modern-table thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .modern-table tr {
        border: 1px solid var(--border-light);
        border-radius: 12px;
        margin-bottom: 1.25rem;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.02);
    }
    
    .modern-table td { 
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
        position: relative;
        padding: 0.65rem 0 0.65rem 40% !important; 
        text-align: left !important;
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    .modern-table td:last-child {
        border-bottom: 0;
        padding-bottom: 0 !important;
    }
    
    .modern-table td::before { 
        position: absolute;
        top: 50%;
        left: 10px;
        transform: translateY(-50%);
        width: 35%; 
        padding-right: 10px; 
        white-space: nowrap;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
    }
    
    /* Specific table layouts depending on context */
    /* 1. Dashboard Website Table (Compact grid layout) */
    .website-table tbody tr {
        display: grid !important;
        grid-template-areas: 
            "name status"
            "pool actions" !important;
        grid-template-columns: 1fr auto !important;
        grid-template-rows: auto auto !important;
        align-items: center;
        gap: 8px 16px !important;
        padding: 12px 14px !important;
        margin-bottom: 0.75rem !important;
    }
    
    .website-table td {
        border: none !important;
        padding: 0 !important;
        min-height: 0 !important;
        position: static !important;
        width: auto !important;
    }
    
    .website-table td::before {
        display: none !important;
    }
    
    .website-table td:nth-of-type(1) { 
        grid-area: name; 
        font-size: 1.05rem !important;
        font-weight: 600 !important;
        border-bottom: none !important;
    }
    .website-table td:nth-of-type(2) { 
        grid-area: pool; 
        font-size: 0.85rem !important;
        color: var(--text-secondary);
        border-bottom: none !important;
    }
    .website-table td:nth-of-type(3) { 
        grid-area: status; 
        text-align: right !important;
        display: flex;
        justify-content: flex-end;
        border-bottom: none !important;
    }
    .website-table td:nth-of-type(4) { 
        grid-area: actions; 
        text-align: right !important;
        display: flex;
        justify-content: flex-end;
        border-bottom: none !important;
    }
    .website-table td:nth-of-type(4) .action-btn-group {
        justify-content: flex-end !important;
        margin-top: 0;
    }

    /* 2. User Management Table */
    .user-management-table td:nth-of-type(1)::before { content: "Username"; }
    .user-management-table td:nth-of-type(2)::before { content: "Mobile"; }
    .user-management-table td:nth-of-type(3)::before { content: "Address"; }
    .user-management-table td:nth-of-type(4)::before { content: "Roles"; }
    .user-management-table td:nth-of-type(5)::before { content: "Password Policy"; }
    .user-management-table td:nth-of-type(6)::before { content: "Status"; }
    .user-management-table td:nth-of-type(7)::before { content: "Actions"; }

    .user-management-table td:nth-of-type(7) {
        text-align: left !important;
    }
    
    .user-management-table td:nth-of-type(7) form {
        display: inline-block;
    }

    /* 3. Audit Log Table */
    .audit-log-table td:nth-of-type(1)::before { content: "Timestamp"; }
    .audit-log-table td:nth-of-type(2)::before { content: "User"; }
    .audit-log-table td:nth-of-type(3)::before { content: "Role"; }
    .audit-log-table td:nth-of-type(4)::before { content: "Action"; }
    .audit-log-table td:nth-of-type(5)::before { content: "Resource"; }
    .audit-log-table td:nth-of-type(6)::before { content: "Prev State"; }
    .audit-log-table td:nth-of-type(7)::before { content: "New State"; }
    .audit-log-table td:nth-of-type(8)::before { content: "Status"; }
    .audit-log-table td:nth-of-type(9)::before { content: "Source IP"; }
    .audit-log-table td:nth-of-type(10)::before { content: "Correlation"; }

    /* 4. Website Permissions Table */
    .permissions-table td:nth-of-type(2)::before { content: "Can View"; }
    .permissions-table td:nth-of-type(3)::before { content: "Can Start"; }
    .permissions-table td:nth-of-type(4)::before { content: "Can Stop"; }
    .permissions-table td:nth-of-type(5)::before { content: "Can Recycle"; }

    .permissions-table td:first-child {
        font-size: 1rem !important;
        font-weight: 600 !important;
        color: #fff !important;
        padding-left: 12px !important;
        background: rgba(255, 255, 255, 0.02) !important;
        border-bottom: 1px solid var(--border-light) !important;
        position: relative !important;
    }
    .permissions-table td:first-child::before {
        display: none !important;
    }
    .permissions-table td:nth-of-type(2),
    .permissions-table td:nth-of-type(3),
    .permissions-table td:nth-of-type(4),
    .permissions-table td:nth-of-type(5) {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center;
        padding-right: 12px !important;
    }
}

/* Accordion details summary chevron rotation */
details[open] .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-chevron {
    transition: transform 0.2s ease-in-out;
}

/* Desktop Modern Table Styles */
.modern-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    background: transparent;
    color: var(--text-primary);
}

.modern-table th {
    padding: 12px 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.modern-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}
