/* ============================================
   REGULUS PORTAL - Styles
   ============================================ */

/* --- Portal Body (dashboard/admin pages) --- */
.portal-body {
    background: #0a0a0a;
    color: #f5f5f7;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
}

/* --- Portal Navigation --- */
.portal-nav {
    background: rgba(29, 29, 31, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 24px;
}

.portal-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.portal-nav-inner .nav-logo img {
    height: 28px;
}

.portal-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.portal-user-info {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.portal-nav-link {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.portal-nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

/* --- Portal Main Content --- */
.portal-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.portal-title {
    font-size: 28px;
    font-weight: 600;
    color: #f5f5f7;
    margin-bottom: 4px;
}

.portal-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
}

/* --- Login Card --- */
.portal-card {
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
}

.portal-card .label {
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--green);
    margin-bottom: 12px;
}

.headline-small {
    font-size: 28px;
    font-weight: 600;
    color: white;
}

.subhead-small {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
}

/* --- Form Fields --- */
.portal-field {
    margin-bottom: 16px;
    text-align: left;
}

.portal-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
}

.portal-field input[type="text"],
.portal-field input[type="password"],
.portal-field input[type="email"],
.portal-field input[type="file"],
.portal-field select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: white;
    font-size: 15px;
    transition: all 0.2s;
    outline: none;
    font-family: inherit;
}

.portal-field input:focus,
.portal-field select:focus {
    border-color: var(--green);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(51, 204, 102, 0.15);
}

.portal-field input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.portal-field select {
    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='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.portal-field select option {
    background: #1d1d1f;
    color: white;
}

/* --- Buttons --- */
.portal-btn {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    padding: 14px 24px;
    font-size: 16px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

.btn-icon {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-icon:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon-danger:hover {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.portal-link-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    cursor: pointer;
    margin-top: 16px;
    text-decoration: underline;
    font-family: inherit;
}

.portal-link-btn:hover {
    color: white;
}

/* --- Error Message --- */
.portal-error {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    color: #ff6b6b;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* --- Footer Text --- */
.portal-footer-text {
    margin-top: 24px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
}

/* --- Backup Codes Grid --- */
.backup-codes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 320px;
    max-width: 100%;
    margin: 0 24px;
}

.backup-code {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
    letter-spacing: 2px;
    text-align: center;
    color: white;
}

/* --- Portal Table --- */
.portal-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.portal-table thead {
    background: rgba(255, 255, 255, 0.05);
}

.portal-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.portal-table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
}

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

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

/* --- File Name Cell --- */
.file-name {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 18px;
    color: var(--green);
    width: 24px;
    text-align: center;
}

.file-title {
    display: block;
    font-weight: 500;
    color: white;
}

.file-desc {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 4px;
}

/* --- User Cell --- */
.user-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- Role Badges --- */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    background: rgba(51, 204, 102, 0.15);
    color: var(--green);
}

.role-customer {
    background: rgba(100, 160, 255, 0.15);
    color: #64a0ff;
}

/* --- Loading / Empty States --- */
.portal-loading {
    text-align: center;
    padding: 48px 24px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 15px;
}

.portal-empty {
    text-align: center;
    padding: 64px 24px;
    color: rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.portal-empty i {
    font-size: 48px;
    margin-bottom: 8px;
}

.portal-muted {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
}

/* --- Modal --- */
.portal-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.portal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.portal-modal-content {
    position: relative;
    background: #1d1d1f;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
}

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

.portal-modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.portal-modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.portal-modal-close:hover {
    color: white;
}

.portal-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* --- Tabs --- */
.portal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0;
}

.portal-tab {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 500;
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.portal-tab:hover {
    color: rgba(255, 255, 255, 0.8);
}

.portal-tab.active {
    color: var(--green);
    border-bottom-color: var(--green);
}

/* --- Checkbox --- */
.portal-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    padding: 6px 0;
}

.portal-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin: 0;
    accent-color: var(--green);
    cursor: pointer;
    vertical-align: middle;
}

.portal-checkbox-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

/* --- Permissions Manager --- */
.perms-manager {
    padding: 8px 0;
}

.perms-folder-group {
    margin-bottom: 24px;
}

.perms-folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

.perms-folder-header .portal-muted {
    margin-left: auto;
    font-weight: 400;
}

.perms-inherited-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(100, 160, 255, 0.08);
    border: 1px solid rgba(100, 160, 255, 0.2);
    border-radius: 8px;
    font-size: 13px;
    color: #64a0ff;
    margin-bottom: 16px;
    line-height: 1.4;
}

.perms-inherited-notice i {
    margin-top: 2px;
    flex-shrink: 0;
}

.perm-inherited {
    opacity: 0.6;
}

/* --- Breadcrumbs --- */
.portal-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    font-size: 14px;
    flex-wrap: wrap;
}

.breadcrumb-link {
    color: var(--green);
    text-decoration: none;
    transition: opacity 0.2s;
}

.breadcrumb-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.breadcrumb-sep {
    color: rgba(255, 255, 255, 0.2);
    font-size: 10px;
}

.breadcrumb-current {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* --- Folder Rows --- */
.folder-row {
    cursor: pointer;
}

.folder-row:hover td {
    background: rgba(255, 255, 255, 0.05);
}

.folder-icon {
    color: #f5c842;
}

.folder-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
}

.folder-link:hover {
    color: var(--green);
    text-decoration: underline;
}

/* --- Upload Progress --- */
.upload-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--green), var(--green-light, #4ade80));
    border-radius: 4px;
    transition: width 0.2s ease;
}

.upload-progress-fill.indeterminate {
    width: 40% !important;
    animation: indeterminate 1.2s ease-in-out infinite;
}

@keyframes indeterminate {
    0%   { margin-left: 0;   width: 40%; }
    50%  { margin-left: 60%; width: 40%; }
    100% { margin-left: 0;   width: 40%; }
}

.upload-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 4px;
}

.upload-progress-info span:first-child {
    color: white;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.upload-progress-info span:last-child {
    color: rgba(255, 255, 255, 0.5);
}

#upload-progress-detail {
    font-size: 12px;
    margin-bottom: 16px;
    font-variant-numeric: tabular-nums;
}

/* --- Portal Login Page: hide theme toggle --- */
.portal-login-page .theme-toggle {
    visibility: hidden;
}

/* --- Portal Login Hero: always dark ---
   The login page uses hero-dark which now adapts per theme.
   Pin it permanently to dark so form elements stay legible
   regardless of the user's site-wide theme preference. */
.portal-login-hero,
.bg-page .portal-login-hero {
    background: rgba(10, 10, 10, 0.95) !important;
    color: #f5f5f7 !important;
}

/* --- Header Actions --- */
.portal-header-actions {
    display: flex;
    gap: 8px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .portal-header {
        flex-direction: column;
    }

    .portal-table {
        display: block;
        overflow-x: auto;
    }

    .portal-nav-right {
        gap: 8px;
    }

    .portal-user-info {
        display: none;
    }

    .portal-modal-content {
        padding: 24px;
    }

    .portal-main {
        padding: 20px 16px;
    }
}
