/*
File: style.css
Location: /fns_admin/css/
Purpose: Main stylesheet for FNS Admin module. Premium, elegant design using Green Africa brand colors.
*/
:root {
    --greenafrica-primary: #2e2260;
    --greenafrica-secondary: #1eff5b;
    --greenafrica-tertiary: #828282;
    --greenafrica-light: #fafbfc;
    --sidebar-bg: #ffffff;
    --sidebar-border: #f0f0f0;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.02), 0 4px 8px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 8px 20px rgba(0,0,0,0.06);
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border-light: #f3f4f6;
    --header-bg: var(--greenafrica-primary);
    --header-text: #ffffff;
    --error-color: #ef4444;
    --success-color: #10b981;
    --metric-bg: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--greenafrica-light);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Premium Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    box-shadow: 0 0 20px rgba(0,0,0,0.02);
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
    padding: 0 2rem;
}

.sidebar .logo {
    width: 100px !important;
    height: 100px !important;
    min-width: 80px;
    min-height: 80px;
    max-width: 80px;
    max-height: 80px;
}

/* Additional enforcement for logo size */
.sidebar-header .logo,
aside.sidebar .logo,
.sidebar .sidebar-header .logo {
    width: 100px !important;
    height: 100px !important;
}

.sidebar h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--greenafrica-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.sidebar nav {
    flex: 1;
    padding: 0 1rem;
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar nav ul li a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.125rem 0;
}

.sidebar nav ul li a i {
    width: 18px;
    font-size: 16px;
    opacity: 0.7;
}

.sidebar nav ul li a.active,
.sidebar nav ul li a:hover {
    background: var(--greenafrica-primary);
    color: white;
    transform: translateX(4px);
}

.sidebar nav ul li a.active i,
.sidebar nav ul li a:hover i {
    opacity: 1;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    background: var(--greenafrica-light);
}

.main-header {
    background: white;
    padding: 2rem 3rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.main-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.03em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.logout-btn {
    color: var(--text-light);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: var(--border-light);
    color: var(--text-secondary);
}

/* Content Area */
.content-area {
    padding: 3rem;
}

/* Premium Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.metric-card {
    background: var(--metric-bg);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.metric-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.metric-icon {
    width: 60px;
    height: 60px;
    background: var(--greenafrica-primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.metric-data h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
    letter-spacing: -0.02em;
}

.metric-data p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 500;
}

/* Activity Section */
.activity-section {
    background: white;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.section-header {
    padding: 2rem 2.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.date-input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    color: var(--text-primary);
}

.refresh-btn {
    background: var(--greenafrica-primary);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: var(--greenafrica-secondary);
    transform: rotate(90deg);
}

.activity-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 2.5rem;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
}

.chart-container {
    background: var(--greenafrica-light);
    border-radius: 12px;
    padding: 2rem;
    height: 400px;
    min-height: 400px;
    max-height: 400px;
    position: relative;
}

.chart-container.half-width {
    width: 100%;
}

.recent-subscriptions h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
}

.subs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.subs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sub-item {
    padding: 1.25rem;
    background: var(--greenafrica-light);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.sub-item:hover {
    background: white;
    box-shadow: var(--card-shadow);
}

.sub-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.5rem;
}

.sub-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sub-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.sub-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.sub-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.sub-pnr {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
    color: var(--greenafrica-primary);
    font-weight: 700;
    background: rgba(46, 34, 96, 0.1);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    display: inline-block;
}

.sub-route {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.sub-date {
    font-size: 0.75rem;
    color: var(--text-light);
}

.sub-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sub-info strong {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.loading, .no-data, .error-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

.error-data {
    color: var(--error-color);
}

/* Enhanced animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-card {
    animation: fadeInUp 0.6s ease forwards;
}

.metric-card:nth-child(1) { animation-delay: 0.1s; }
.metric-card:nth-child(2) { animation-delay: 0.2s; }
.metric-card:nth-child(3) { animation-delay: 0.3s; }
.metric-card:nth-child(4) { animation-delay: 0.4s; }
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
    
    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .main-header {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .content-area {
        padding: 1.5rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .metric-card {
        padding: 1.5rem;
    }
    
    .section-header {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .activity-grid {
        padding: 1.5rem;
        gap: 1.5rem;
    }
    
    .charts-row {
        grid-template-columns: 1fr;
    }
    
    .summary-card {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    .summary-section:first-child,
    .summary-section:nth-child(2) {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        padding-right: 0;
        padding-bottom: 1.5rem;
    }
    
    .sub-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}

/* Error Toast Notifications */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff4757;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.error-toast i {
    font-size: 16px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced refresh button animation */
.refresh-btn .fa-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Enhanced section header with better filter controls */
.enhanced-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-row .date-input {
    min-width: 120px;
}

.filter-row .refresh-btn {
    min-width: 40px;
    padding: 0.5rem;
}

/* Chart enhancements */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.125rem;
}

.chart-legend {
    display: flex;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Search Summary */
.search-summary {
    margin-bottom: 2rem;
    width: 100%;
}

.summary-card {
    background: linear-gradient(135deg, var(--greenafrica-primary), var(--greenafrica-secondary));
    color: white;
    padding: 2rem;
    border-radius: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2rem;
    box-shadow: var(--card-shadow);
    width: 100%;
    align-items: center;
}

.summary-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.summary-section:first-child {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    padding-right: 2rem;
}

.summary-section:nth-child(2) {
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    padding-right: 2rem;
}

.summary-icon {
    background: rgba(255, 255, 255, 0.2);
    padding: 1rem;
    border-radius: 10px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.summary-main h3 {
    margin: 0 0 0.25rem 0;
    font-size: 2rem;
    font-weight: 700;
}

.summary-main p {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    opacity: 0.9;
}

.summary-meta {
    font-size: 0.75rem;
    opacity: 0.8;
    font-style: italic;
}

.summary-stats-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.stat-item i {
    font-size: 1.5rem;
    opacity: 0.9;
    width: 30px;
    text-align: center;
}

.stat-item div {
    display: flex;
    flex-direction: column;
}

.stat-item strong {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-item span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.summary-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.breakdown-item i {
    font-size: 1.5rem;
    opacity: 0.9;
    width: 30px;
    text-align: center;
}

.breakdown-item div {
    display: flex;
    flex-direction: column;
}

.breakdown-item strong {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.breakdown-item span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.breakdown-item i {
    width: 16px;
    font-size: 0.8rem;
}

.breakdown-item strong {
    font-weight: 600;
}

.summary-meta {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Right Panel Layout */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.recent-subscriptions {
    flex: 1;
}

.recent-subscriptions h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 1.5rem 0;
}

/* Responsive chart updates */
@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-row .date-input {
        min-width: auto;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .chart-legend {
        flex-wrap: wrap;
    }
    
    .summary-card {
        flex-direction: column;
        text-align: center;
    }
}

/* Preferences Display Styles */
.preferences-container {
    max-width: 200px;
    font-size: 0.85rem;
}

.preference-item {
    margin-bottom: 6px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
}

.preference-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.preference-time {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
    margin-bottom: 3px;
}

.preference-channels {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.channel-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid;
}

.channel-whatsapp {
    background-color: #e7f5e7;
    color: #25d366;
    border-color: #25d366;
}

.channel-sms {
    background-color: #fff3e0;
    color: #ff9800;
    border-color: #ff9800;
}

.channel-email {
    background-color: #e3f2fd;
    color: #2196f3;
    border-color: #2196f3;
}

.channel-push {
    background-color: #f3e5f5;
    color: #9c27b0;
    border-color: #9c27b0;
}

.channel-default {
    background-color: #f5f5f5;
    color: var(--text-secondary);
    border-color: var(--text-secondary);
}

/* Table cell styling for preferences column */
#subscriptions-table tbody td:nth-child(9) {
    vertical-align: top;
    padding-top: 12px;
    padding-bottom: 12px;
}

/* ─── Sidebar footer (user info) ─────────────────────────────── */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ─── User management page ───────────────────────────────────── */
.add-user-form .form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.add-user-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.add-user-form .form-group:first-child {
    flex: 1;
    min-width: 200px;
}

.add-user-form .form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.add-user-form .form-group input,
.add-user-form .form-group select {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
}

.form-msg {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.msg-success {
    background: #e6f9ee;
    color: #1a7a3a;
}

.msg-error {
    background: #fdeaea;
    color: #b91c1c;
}

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.role-select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
    cursor: pointer;
}

.btn {
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: opacity 0.15s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background: var(--greenafrica-primary);
    color: #fff;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ─── Microsoft SSO button ───────────────────────────────────── */
.microsoft-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    width: 100%;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: opacity 0.15s;
}

.microsoft-btn:hover {
    opacity: 0.9;
}
