:root {
    --bg-primary: #121217;
    --bg-secondary: #1E1E28;
    --accent-primary: #00CED1;
    --text-primary: #E0E0E0;
    --text-muted: #A0A0A0;
    --error: #ef4444;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.portal-view {
    display: block;
}

.portal-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

/* Header Styles */
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.portal-logo {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.header-title-group {
    display: flex;
    flex-direction: column;
}

.case-header-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 2px 0 0 0;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0;
    cursor: pointer;
    width: auto;
    display: flex;
    align-items: center;
}

.logout-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    width: auto;
}

/* Main Content */
.portal-main {
    padding: 1.5rem;
}

.portal-welcome {
    margin-bottom: 2rem;
}

.portal-welcome h2 {
    font-size: 1.8rem;
    margin: 0 0 0.5rem 0;
}

.case-subtitle {
    color: var(--text-muted);
    margin: 0;
    font-size: 1rem;
}

/* Tabs */
.portal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none; /* Firefox */
}

.portal-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.tab-btn {
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    width: auto;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #000;
}

.tab-btn {
    position: relative;
}

.tab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #ef4444; /* Red color */
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
}

/* Search/Filter Bar */
.search-filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input-wrapper {
    position: relative;
    flex-grow: 1;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper input {
    padding-left: 40px;
    background-color: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.filter-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 0;
    cursor: pointer;
}

.filter-wrapper {
    position: relative;
}

.filter-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 250px;
    background-color: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    display: none;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.filter-menu.show {
    display: block;
}

.filter-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.filter-menu-header span {
    font-weight: 600;
    font-size: 0.9rem;
}

.text-btn {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-section label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.filter-input {
    background-color: var(--bg-primary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 8px;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
}

/* Tab Content */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Objectives List */
.objectives-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.objective-card {
    background-color: var(--bg-secondary);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.objective-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.objective-title-group {
    flex-grow: 1;
}

.objective-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
}

.objective-summary {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.4;
}

.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.status-in_progress { background-color: #f59e0b; color: #000; }
.status-completed { background-color: #10b981; color: #000; }
.status-approved { background-color: var(--accent-primary); color: #000; }
.status-assigned { background-color: #6366f1; color: #fff; }
.status-draft { background-color: #6b7280; color: #fff; }

.objective-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    background-color: rgba(0, 0, 0, 0.1);
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.info-item svg {
    color: var(--text-muted);
}

.info-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 2px;
}

.progress-container {
    width: 100%;
    margin-top: 0.5rem;
}

.progress-bar-bg {
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--accent-primary);
    transition: width 0.3s ease;
}

/* Empty States */
.empty-state, .loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .portal-main {
        padding: 1rem;
    }
    
    .objective-header {
        flex-direction: column-reverse;
        align-items: flex-start;
    }
    
    .status-badge {
        align-self: flex-start;
        margin-bottom: 0.5rem;
    }
    
    .objective-footer {
        flex-direction: column;
        gap: 0.75rem;
    }
}

.login-container {
    width: 100%;
    max-width: 320px;
    padding: 2rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.form-group {
    margin-bottom: 1rem;
}

input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-primary);
    box-sizing: border-box;
    font-size: 1rem;
}

input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

button {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-primary);
    border: none;
    border-radius: 4px;
    color: #000;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.9;
}

.error-message {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 1rem;
    text-align: center;
    min-height: 1.2rem;
}

/* Media Gallery */
.portal-container {
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.media-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
}

.media-item:hover {
    transform: translateY(-4px);
}

.media-item img, .media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-wrapper {
    position: relative;
    height: 200px;
    width: 100%;
}

.watermark {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 250px;
    height: 100px;
    background-image: url('https://pharoscms.com/assets/images/pharos_watermark.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom right;
    pointer-events: none; /* Allow clicks to pass through to the image */
    opacity: 0.8;
    z-index: 10;
    max-width: 40%; /* Ensure it doesn't cover too much on small grid items */
}

.modal-media-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.modal-media-wrapper img, .modal-media-wrapper video {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

.modal-media-wrapper .watermark {
    bottom: 20px;
    right: 20px;
    width: 250px;
    height: 150px;
    max-width: 30%;
}

.media-info {
    padding: 1rem;
}

.media-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2rem;
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 8px 16px;
    font-size: 0.8rem;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#modal-body {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#modal-body img, #modal-body video {
    max-width: 100%;
    max-height: calc(90vh - 40px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.close {
    position: absolute;
    top: -40px;
    right: 0;
    color: #f1f1f1;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: var(--accent-primary);
    text-decoration: none;
}

@media (max-width: 768px) {
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .media-item img, .media-item video {
        height: 150px;
    }
    
    .modal-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .close {
        top: -35px;
        right: 5px;
        font-size: 35px; /* Larger on mobile for easier tapping */
    }
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color var(--transition-speed);
    padding: 10px 12px;
    border-radius: 6px;
}

/* ============================================
   4. BUTTONS
   ============================================ */

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    border: 2px solid var(--accent-primary) !important;
    color: var(--accent-primary) !important;
    background-color: transparent !important;
}

.btn-primary:hover {
    background: rgba(var(--primary-rgb), 0.2) !important;
}


.btn-secondary {
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-weight: 500;
    background-color: transparent;
}

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

.btn-success {
    background: var(--green);
    color: white;
}

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-warning {
    background: var(--orange);
    color: white;
}

.btn-audit {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-audit:hover {
    background: #00B8BB;
}

/* Button Sizes */
.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* Chat Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 350px);
    min-height: 400px;
    background-color: var(--bg-secondary);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-header-info {
    padding: 10px 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-online { background-color: var(--accent-primary); box-shadow: 0 0 5px var(--accent-primary); }
.status-connecting { background-color: #f59e0b; }
.status-offline { background-color: #ef4444; }

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.message-left {
    align-self: flex-start;
    background-color: #2D2D3A;
    border-bottom-left-radius: 4px;
}

.message-right {
    align-self: flex-end;
    background-color: var(--accent-primary);
    color: #000;
    border-bottom-right-radius: 4px;
}

.message-info {
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.7;
}

.message-right .message-info {
    text-align: right;
    color: #000;
}

.message-time {
    font-size: 0.7rem;
    margin-top: 4px;
    display: block;
    opacity: 0.6;
}

.message-right .message-time {
    text-align: right;
}

.chat-composer {
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-composer textarea {
    flex-grow: 1;
    background-color: #121217;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 10px 12px;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    font-size: 0.95rem;
}

.chat-composer button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background-color: var(--accent-primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.chat-composer button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Chat system message */
.system-message {
    align-self: center;
    background-color: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 10px 0;
    text-align: center;
    max-width: 90%;
}

/* Media Modal Styles */
.media-modal-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    background: #1a1a1a;
}

.media-modal-container img, 
.media-modal-container video {
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

@media (max-width: 768px) {
    .gallery-nav-btn {
        width: 40px;
        height: 40px;
        background: rgba(0, 0, 0, 0.3);
    }
    .prev-btn { left: 10px; }
    .next-btn { right: 10px; }
}

.unsupported-media {
    flex-direction: column;
    text-align: center;
    color: var(--text-muted);
}

.btn-download {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background-color: var(--accent-primary);
    color: #000;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
}

.media-modal-item {
    display: none;
}
.filter-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}
