﻿/* PixelReports - Modern Enterprise Dashboard Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;700&display=swap');

:root {
    /* Color Palette - Enterprise Professional */
    --primary: #1a237e;
    --primary-light: #3949ab;
    --primary-dark: #0d1445;
    --secondary: #37474f;
    --secondary-light: #546e7a;

    --accent: #ff6f00;
    --accent-light: #ff9800;
    --accent-dark: #e65100;

    --success: #2e7d32;
    --success-light: #4caf50;
    --warning: #f57c00;
    --warning-light: #ffb74d;
    --danger: #c62828;
    --danger-light: #ef5350;

    --bg-main: #f5f7fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1a237e;
    --bg-input: #ffffff;

    --text-main: #263238;
    --text-secondary: #546e7a;
    --text-muted: #90a4ae;
    --text-light: #ffffff;
    --text-sidebar: rgba(255, 255, 255, 0.85);

    --border-color: #e0e6ed;
    --border-light: #eceff1;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --sidebar-width: 260px;
    --header-height: 60px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
.brand-font {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* ================================
   LAYOUT - Desktop Sidebar
================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-light);
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.sidebar-logo span {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-sidebar);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-light);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.12);
    border-left-color: var(--accent);
    color: var(--text-light);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item.logout {
    color: rgba(255, 255, 255, 0.6);
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item.logout:hover {
    color: var(--danger-light);
    background: rgba(198, 40, 40, 0.15);
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Header Bar */
.top-header {
    background: var(--bg-card);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Container */
.container {
    padding: 2rem;
    flex: 1;
}

/* ================================
   CARDS
================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.stat-card .icon-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card .icon-box svg {
    width: 22px;
    height: 22px;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    margin: 0.25rem 0;
}

.stat-card .trend {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-card .link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.stat-card .link:hover {
    color: var(--accent);
}

/* Stat card variations */
.stat-card.danger::before {
    background: var(--danger);
}

.stat-card.success::before {
    background: var(--success);
}

.stat-card.warning::before {
    background: var(--warning);
}

.stat-card.accent::before {
    background: var(--accent);
}

/* ================================
   TABLES
================================ */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--bg-main);
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: rgba(26, 35, 126, 0.03);
}

/* ================================
   FORMS
================================ */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg-input);
    color: var(--text-main);
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2390a4ae' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* ================================
   BUTTONS
================================ */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

button,
.btn-primary {
    background: var(--primary);
    color: var(--text-light);
}

button:hover,
.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-accent {
    background: var(--accent);
    color: var(--text-light);
}

.btn-accent:hover {
    background: var(--accent-dark);
}

.btn-success {
    background: var(--success);
    color: var(--text-light);
}

.btn-success:hover {
    background: var(--success-light);
}

.btn-danger {
    background: var(--danger);
    color: var(--text-light);
}

.btn-danger:hover {
    background: var(--danger-light);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

/* ================================
   BADGES
================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-Nova {
    background: rgba(46, 125, 50, 0.12);
    color: var(--success);
}

.status-Vista {
    background: rgba(245, 124, 0, 0.12);
    color: var(--warning);
}

.status-Resolvida {
    background: rgba(84, 110, 122, 0.12);
    color: var(--text-secondary);
}

/* ================================
   MODALS
================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ================================
   ALERTS
================================ */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-error {
    background: rgba(198, 40, 40, 0.1);
    color: var(--danger);
    border: 1px solid rgba(198, 40, 40, 0.2);
}

.alert-success {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success);
    border: 1px solid rgba(46, 125, 50, 0.2);
}

.alert-warning {
    background: rgba(245, 124, 0, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 124, 0, 0.2);
}

/* ================================
   UTILITIES
================================ */
.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* ================================
   LOGIN PAGE
================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo svg {
    width: 56px;
    height: 56px;
    color: var(--accent);
}

.login-logo h2 {
    margin-top: 1rem;
    font-size: 1.5rem;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* ================================
   PUBLIC FORM (registar.php)
================================ */
.public-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.public-card {
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.public-header {
    text-align: center;
    margin-bottom: 2rem;
}

.public-header svg {
    width: 52px;
    height: 52px;
    color: var(--accent);
    margin-bottom: 1rem;
}

.public-header h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.public-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.success-view {
    text-align: center;
    display: none;
}

.success-view svg {
    width: 72px;
    height: 72px;
    color: var(--success);
    margin-bottom: 1.25rem;
}

.form-status {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    display: none;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ================================
   MOBILE RESPONSIVE
================================ */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    /* Mobile Bottom Navigation */
    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        padding: 0.5rem 0;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }

    .mobile-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
        color: var(--text-muted);
        font-size: 0.65rem;
        font-weight: 500;
        gap: 0.25rem;
        transition: var(--transition);
    }

    .mobile-nav a svg {
        width: 22px;
        height: 22px;
    }

    .mobile-nav a.active {
        color: var(--primary);
    }

    .mobile-nav a.active svg {
        color: var(--accent);
    }

    .mobile-nav a.logout {
        color: var(--danger);
    }

    /* Mobile Header */
    .top-header {
        padding: 1rem;
    }

    .top-header .mobile-logo {
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
    }

    .top-header .mobile-logo svg {
        width: 28px;
        height: 28px;
        color: var(--accent);
    }

    .top-header .mobile-logo span {
        font-family: 'Outfit', sans-serif;
        font-weight: 700;
        font-size: 1.1rem;
        color: var(--primary);
    }

    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .value {
        font-size: 1.5rem;
    }

    .stat-card .icon-box {
        width: 36px;
        height: 36px;
    }

    .stat-card .icon-box svg {
        width: 18px;
        height: 18px;
    }

    .flex-between {
        flex-direction: column;
        align-items: stretch;
    }

    .flex-between>div {
        text-align: center;
    }

    .flex-between>button,
    .flex-between>a.btn,
    .flex-between>a.btn-accent {
        width: 100%;
    }

    /* Tables Mobile */
    .table-responsive {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    th,
    td {
        padding: 0.75rem 0.875rem;
        font-size: 0.8rem;
    }

    th {
        font-size: 0.65rem;
    }

    /* Hide less important columns */
    th:nth-child(n+4):not(:last-child),
    td:nth-child(n+4):not(:last-child) {
        display: none;
    }

    /* Forms Mobile */
    input,
    select,
    textarea {
        padding: 0.875rem 1rem;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Modal Mobile */
    .modal-content {
        max-width: 100%;
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        border-radius: var(--radius-md);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .stat-card .header {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .stat-card .icon-box {
        align-self: flex-end;
    }

    .public-card {
        padding: 1.5rem;
    }

    .login-card {
        padding: 2rem;
    }
}

/* Desktop: Hide mobile elements */
@media (min-width: 993px) {
    .mobile-nav {
        display: none !important;
    }

    .top-header .mobile-logo {
        display: none !important;
    }
}

/* ================================
   PRINT STYLES
================================ */
@media print {

    .sidebar,
    .mobile-nav,
    .top-header {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .modal-overlay {
        position: absolute;
        background: white !important;
    }

    button,
    .btn {
        display: none;
    }
}

/* ================================
   MOBILE CARD TABLES & ENHANCEMENTS
   ================================ */
@media (max-width: 992px) {

    /* Transform Tables to Cards */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    /* Hide Header Row */
    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive tr {
        border: 1px solid var(--border-color);
        margin-bottom: 1rem;
        background: var(--bg-card);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        padding: 0;
        overflow: hidden;
    }

    .table-responsive td {
        border: none;
        border-bottom: 1px solid var(--border-light);
        position: relative;
        padding: 0.875rem 1rem;
        padding-left: 40%;
        text-align: right;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        min-height: 48px;
    }

    .table-responsive td:before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: var(--text-secondary);
        top: 50%;
        transform: translateY(-50%);
    }

    /* Override hidden columns rule */
    th:nth-child(n+4):not(:last-child),
    td:nth-child(n+4):not(:last-child) {
        display: flex !important;
    }

    /* Actions Row */
    .table-responsive td:last-child {
        border-bottom: none;
        display: flex;
        justify-content: center;
        padding: 1rem;
        padding-left: 1rem;
        background: var(--bg-main);
    }

    .table-responsive td:last-child:before {
        display: none;
    }

    .table-responsive td:last-child div {
        width: 100%;
        justify-content: space-between !important;
    }

    .table-responsive td:last-child button {
        flex: 1;
    }

    /* Make QR Button Full Width in Mobile */
    .qr-btn {
        width: 100% !important;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    /* Modal Mobile Fixes */
    .modal-content {
        margin: 1rem;
        width: auto;
        max-width: none;
    }
}
