/**
 * Admin Panel Responsive Styles
 * Mobile-first approach for Rewards App admin
 */

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1050;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border: none;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.05);
}

.mobile-menu-toggle i {
    font-size: 20px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1030;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Mobile responsive breakpoints */
@media (max-width: 991.98px) {
    .mobile-menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        left: -280px;
        width: 280px !important;
        max-width: 85vw;
        height: 100vh !important;
        z-index: 1040;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding-top: 70px !important;
    }

    .sidebar.show {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 70px !important;
    }

    /* Fix container fluid */
    .container-fluid > .row {
        margin: 0;
    }

    .container-fluid > .row > .col-md-9,
    .container-fluid > .row > .col-lg-9 {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    /* Cards responsive */
    .card {
        margin-bottom: 15px;
    }

    .card-body {
        padding: 15px;
    }

    /* Form rows responsive */
    .row > [class*="col-md-"] {
        margin-bottom: 15px;
    }

    /* Stat cards */
    .stat-card {
        padding: 20px;
    }

    .stat-number {
        font-size: 32px !important;
    }

    .stat-icon {
        font-size: 36px !important;
    }

    /* Page titles */
    .page-title {
        font-size: 1.5rem;
    }

    .page-title i {
        font-size: 28px !important;
    }

    /* Button groups */
    .card-body .d-flex.flex-wrap.gap-2 {
        flex-direction: column;
    }

    .card-body .d-flex.flex-wrap.gap-2 .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    .card-body .d-flex.justify-content-between {
        flex-direction: column;
        gap: 15px;
    }

    /* Search forms */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .d-flex.gap-2 > .form-control {
        flex: 1 1 100%;
        margin-bottom: 10px;
    }

    .d-flex.gap-2 > .btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 767.98px) {
    /* Smaller mobile adjustments */
    .main-content {
        padding: 15px !important;
    }

    h1, .h1 {
        font-size: 1.5rem;
    }

    h2, .h2 {
        font-size: 1.3rem;
    }

    /* Tables responsive */
    .table-responsive {
        font-size: 0.85rem;
    }

    .table th, .table td {
        padding: 8px 10px;
        white-space: nowrap;
    }

    /* Hide non-essential columns on mobile */
    .table .hide-mobile {
        display: none;
    }

    /* Form elements */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 10px 16px;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Alert adjustments */
    .alert {
        padding: 12px;
        font-size: 0.9rem;
    }

    /* Stat cards even smaller */
    .stat-number {
        font-size: 28px !important;
    }

    /* Quick actions cards */
    .quick-action-card {
        padding: 15px !important;
    }

    .quick-action-card h5 {
        font-size: 1rem;
    }
}

@media (max-width: 575.98px) {
    /* Extra small devices */
    .card-header h5 {
        font-size: 1rem;
    }

    .mobile-menu-toggle {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
    }

    .sidebar {
        padding-top: 60px !important;
    }

    .main-content {
        padding-top: 60px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Tables even smaller */
    .table-responsive {
        font-size: 0.8rem;
    }

    .table .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* Full width buttons */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }
}

/* Landscape mobile */
@media (max-width: 991.98px) and (orientation: landscape) {
    .sidebar {
        padding-top: 50px !important;
    }

    .main-content {
        padding-top: 50px !important;
    }
}

/* Shared look: buttons, cards, fields, tables */
:root {
    --pa-ink: #0f3460;
    --pa-teal: #0d9373;
    --pa-teal-2: #14b8a6;
    --pa-line: #e7edf3;
    --bs-link-color: #0d7a62;
    --bs-link-hover-color: #0b5e4c;
    --bs-link-color-rgb: 13, 122, 98;
    --bs-link-hover-color-rgb: 11, 94, 76;
}

.btn {
    border-radius: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border: none;
    box-shadow: 0 8px 18px rgba(29, 78, 216, .22);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    box-shadow: 0 10px 22px rgba(29, 78, 216, .28);
}

.btn-success {
    background: linear-gradient(135deg, var(--pa-teal-2) 0%, var(--pa-teal) 100%);
    border: none;
    box-shadow: 0 8px 18px rgba(13, 147, 115, .22);
}

.btn-success:hover,
.btn-success:focus {
    background: linear-gradient(135deg, #0f9f86 0%, #0b7a5e 100%);
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, #67e8f9 0%, #22d3ee 100%);
    border: none;
    color: #083344;
}

.btn-outline-primary,
.btn-outline-success,
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-info {
    background: #fff;
    border-width: 1.5px;
}

.btn-outline-success {
    color: var(--pa-teal);
    border-color: #8ed9c8;
}

.btn-outline-success:hover {
    background: #f0fdf9;
    color: #0b7a5e;
    border-color: var(--pa-teal);
}

.btn-outline-primary {
    --bs-btn-color: #1e3a5f;
    --bs-btn-border-color: #c9d5e4;
    --bs-btn-hover-color: #0f3460;
    --bs-btn-hover-bg: #f4f7fb;
    --bs-btn-hover-border-color: #b7c6d8;
    --bs-btn-active-color: #0f3460;
    --bs-btn-active-bg: #e8eef5;
    --bs-btn-active-border-color: #b7c6d8;
    --bs-btn-disabled-color: #1e3a5f;
    --bs-btn-disabled-border-color: #c9d5e4;
    color: #1e3a5f;
    border-color: #c9d5e4;
    background: #fff;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: #f4f7fb;
    color: #0f3460;
    border-color: #b7c6d8;
}

.btn-lg {
    border-radius: 13px;
    padding: .7rem 1.15rem;
}

.card {
    border: 1px solid rgba(15, 52, 96, .06);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(15, 52, 96, .06);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--pa-line);
    border-radius: 16px 16px 0 0 !important;
}

.form-control,
.form-select {
    border-radius: 11px;
    border-color: #dbe3ec;
    background: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--pa-teal-2);
    box-shadow: 0 0 0 .2rem rgba(20, 184, 166, .16);
}

.form-label {
    font-weight: 600;
    color: #334155;
}

.form-check-input:checked {
    background-color: #0d9373;
    border-color: #0d9373;
}

.main-content a:not(.btn):not(.nav-link),
.card-body a:not(.btn):not(.nav-link),
.alert-link {
    color: #0d7a62 !important;
    font-weight: 600;
    text-decoration: none;
}

.main-content a:not(.btn):not(.nav-link):hover,
.card-body a:not(.btn):not(.nav-link):hover,
.alert-link:hover {
    color: #0b5e4c !important;
    text-decoration: underline;
}

.page-link {
    color: #0d7a62;
}

.page-link:hover {
    color: #0b5e4c;
}

.table {
    --bs-table-bg: transparent;
}

.table thead th {
    font-size: .75rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
    border-bottom-color: var(--pa-line);
}

.table > :not(caption) > * > * {
    padding-top: .85rem;
    padding-bottom: .85rem;
}

.badge {
    border-radius: 999px;
    font-weight: 600;
    padding: .4em .7em;
}

.alert {
    border: none;
    border-radius: 14px;
}

.pa-tabs,
.nav-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    background: #f1f5f9;
    border: none;
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 0;
}

.pa-tabs .nav-link,
.nav-tabs .nav-link {
    border: 0 !important;
    border-radius: 10px !important;
    color: #5c6b7a !important;
    background: transparent !important;
    font-weight: 600;
    padding: .55rem .95rem;
    white-space: nowrap;
    box-shadow: none !important;
}

.pa-tabs .nav-link:hover,
.pa-tabs .nav-link:focus,
.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus {
    color: #0f3460 !important;
    background: rgba(255, 255, 255, .65) !important;
}

.pa-tabs .nav-link.active,
.nav-tabs .nav-link.active {
    color: #0f3460 !important;
    background: #fff !important;
    box-shadow: 0 1px 2px rgba(15, 52, 96, .08), 0 6px 16px rgba(15, 52, 96, .06) !important;
}

.plan-pill {
    display: inline-block;
    margin-left: .35rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: #0d7a62;
    background: #e7f6f1;
    border-radius: 999px;
    padding: .12rem .45rem;
    vertical-align: 1px;
}

.sidebar .nav-label {
    color: #d6dee8 !important;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin: 16px 8px 6px;
}

.modal-content {
    border: none;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 52, 96, .18);
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .sidebar a {
        padding: 14px 15px !important;
        margin-bottom: 4px !important;
    }

    .btn {
        min-height: 44px;
    }

    .form-control, .form-select {
        min-height: 44px;
    }
}
