/* =============================================
   RTS Partner Portal & Staff Admin Styles
   ============================================= */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Layout */
.portal-body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f6f8;
    color: #222;
    min-height: 100vh;
}

.portal-header {
    background: #fff;
    border-bottom: 2px solid #8b0000;
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 15px 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.portal-logo {
    height: 120px;
    width: auto;
    display: block;
    transition: height 0.3s ease;
}

/* Hamburger */
.portal-hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    z-index: 200;
}

.portal-hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: #333;
    border-radius: 2px;
    transition: all 0.25s ease;
    transform-origin: center;
}

.portal-hamburger.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.portal-hamburger.open span:nth-child(2) { opacity: 0; }
.portal-hamburger.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* Mobile menu */
.portal-mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    border-bottom: 2px solid #8b0000;
    z-index: 150;
    flex-direction: column;
}

.portal-mobile-menu.open {
    display: flex;
}

.portal-mobile-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    text-decoration: none;
    color: #333;
    font-size: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.portal-mobile-menu a:last-child {
    border-bottom: none;
}

.portal-mobile-menu a:hover {
    background: #f5f6f8;
    color: #8b0000;
}

.portal-mobile-menu a i {
    width: 18px;
    color: #8b0000;
}

/* Portal Nav */
.portal-nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.portal-nav a {
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.portal-nav a:hover {
    color: #8b0000;
}

/* User menu */
.portal-user-menu {
    position: relative;
}

.portal-user-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 7px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
}

.portal-user-btn:hover {
    border-color: #8b0000;
    color: #8b0000;
}

.portal-user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 200;
}

.portal-user-dropdown.open {
    display: block;
}

.portal-user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
}

.portal-user-dropdown a:hover {
    background: #f5f6f8;
    color: #8b0000;
}

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

/* Alerts */
.portal-alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.portal-alert-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.6;
    color: inherit;
}

.portal-alert-close:hover {
    opacity: 1;
}

.portal-alert-success {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
}

.portal-alert-error {
    background: #fdecea;
    border: 1px solid #ef9a9a;
    color: #c62828;
}

/* Login */
.portal-login-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 130px);
}

.portal-login-box {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.portal-login-box h2 {
    margin: 0 0 6px;
    font-size: 22px;
    color: #111;
}

.portal-login-sub {
    color: #666;
    font-size: 14px;
    margin: 0 0 24px;
}

.portal-login-footer {
    margin-top: 20px;
    font-size: 13px;
    color: #666;
    text-align: center;
}

.portal-login-footer a {
    color: #8b0000;
}

/* Content */
.portal-content {
    width: 100%;
    max-width: 1100px;
}

.portal-page-header {
    margin-bottom: 28px;
}

.portal-page-header h1 {
    margin: 0 0 6px;
    font-size: 26px;
    color: #111;
}

.portal-page-header p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Cards */
.portal-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 24px;
}

.portal-card h2 {
    margin: 0 0 18px;
    font-size: 17px;
    color: #111;
}

.portal-urgent {
    border-left: 4px solid #8b0000;
}

/* Form fields */
.portal-field {
    margin-bottom: 16px;
}

.portal-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 5px;
}

.portal-field input,
.portal-field select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.portal-field input:focus,
.portal-field select:focus {
    outline: none;
    border-color: #8b0000;
}

.portal-field input:disabled {
    background: #f5f6f8;
    color: #888;
    cursor: not-allowed;
}

.portal-hint {
    font-size: 11px;
    color: #999;
    font-weight: normal;
    display: block;
    margin-top: 3px;
}

.portal-password-wrap {
    position: relative;
}

.portal-password-wrap input {
    padding-right: 40px;
}

.portal-password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 0;
    font-size: 15px;
    line-height: 1;
}

.portal-password-toggle:hover {
    color: #555;
}

/* Buttons */
.portal-btn-primary {
    background: #8b0000;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.portal-btn-primary:hover {
    background: #6b0000;
}

.portal-btn-secondary {
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.portal-btn-secondary:hover {
    border-color: #8b0000;
    color: #8b0000;
}

.portal-btn-danger {
    background: #fff;
    color: #c62828;
    border: 1px solid #ef9a9a;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.portal-btn-danger:hover {
    background: #fdecea;
}

.portal-btn-muted {
    background: #fff;
    color: #444;
    border: 1px solid #888;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.portal-btn-muted:hover {
    background: #888;
    color: #fff;
}

.portal-btn-success {
    background: #fff;
    color: #1565c0;
    border: 1px solid #1565c0;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.portal-btn-success:hover {
    background: #1565c0;
    color: #fff;
}

.portal-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Tables */
.portal-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 560px;
}

.portal-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #e0e0e0;
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    letter-spacing: 0.5px;
}

.portal-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

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

.portal-actions {
    display: flex;
    gap: 8px;
}

.portal-actions button {
    min-width: 110px;
    text-align: center;
}

.portal-expired {
    color: #c62828;
    font-weight: 600;
}

/* Badges */
.portal-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.portal-badge-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.portal-badge-pending {
    background: #fff8e1;
    color: #f57f17;
}

.portal-badge-inactive {
    background: #f5f5f5;
    color: #757575;
}

/* File grid (partner dashboard) */
.portal-category {
    margin-bottom: 36px;
}

.portal-category-title {
    font-size: 16px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.portal-file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.portal-file-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.portal-file-icon {
    font-size: 28px;
    color: #8b0000;
    flex-shrink: 0;
    margin-top: 2px;
}

.portal-file-info {
    flex: 1;
}

.portal-file-info h3 {
    margin: 0 0 4px;
    font-size: 15px;
    color: #111;
}

.portal-file-info p {
    margin: 0 0 6px;
    font-size: 13px;
    color: #666;
}

.portal-file-type {
    font-size: 11px;
    color: #999;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.portal-btn-download {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #8b0000;
    color: #fff;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
    white-space: nowrap;
}

.portal-btn-download:hover {
    background: #6b0000;
}

/* Settings grid */
.portal-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

/* Inline form */
.portal-inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.portal-inline-form .portal-field {
    margin-bottom: 0;
}

/* Empty state */
.portal-empty {
    color: #999;
    font-size: 14px;
    padding: 16px 0;
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 768px) {
    .portal-header-inner {
        padding: 10px 16px;
    }

    .portal-nav {
        gap: 14px;
    }

    .portal-nav {
        display: none;
    }

    .portal-hamburger {
        display: flex;
    }

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

    .portal-card {
        padding: 16px;
    }

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

    /* Inline add-partner form: stack vertically */
    .portal-inline-form {
        grid-template-columns: 1fr;
    }

    .portal-inline-form button {
        width: 100%;
    }

    /* Settings grid: single column */
    .portal-settings-grid {
        grid-template-columns: 1fr;
    }

    /* File grid: single column */
    .portal-file-grid {
        grid-template-columns: 1fr;
    }

    /* File cards: stack icon/info/button vertically */
    .portal-file-card {
        flex-direction: column;
        gap: 12px;
    }

    .portal-btn-download {
        width: 100%;
        justify-content: center;
    }

    /* Action buttons: full width stacked */
    .portal-actions {
        flex-direction: column;
        gap: 6px;
    }

    .portal-actions button {
        min-width: unset;
        width: 100%;
    }

    /* Login box: tighter padding */
    .portal-login-box {
        padding: 24px 20px;
    }
}

@media (max-width: 480px) {
    .portal-main {
        padding: 16px 12px;
    }

    .portal-card {
        padding: 14px 12px;
        border-radius: 4px;
    }

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

    .portal-card h2 {
        font-size: 15px;
    }

    .portal-login-box {
        padding: 20px 16px;
    }

    .portal-user-btn span,
    .portal-user-btn .fa-chevron-down {
        display: none;
    }
}
