/**
 * Ticket Tailor - Admin Styles
 * Version: 3.1 - Enhanced with Canadian/UK English
 */

/* General Admin Styles */
.ticket-tailor-admin h1 {
    margin-bottom: 1.5rem;
}

.ticket-tailor-admin .description {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #646970;
}

/* Dashboard Stats Grid - FIXED VERSION */
.tt-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.tt-stat-card {
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
    text-align: center;
}

.tt-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Fixed: Use tt-stat-value for the number */
.tt-stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    color: #2271b1;
    margin-bottom: 0.75rem;
}

.tt-stat-label {
    display: block;
    font-size: 0.875rem;
    color: #50575e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Quick Actions Section - FIXED FOR BUTTON DISPLAY */
.tt-quick-actions {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: visible; /* Ensure buttons aren't cut off */
}

.tt-quick-actions h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: #1d2327;
}

.tt-quick-actions .button-group {
    display: flex;
    gap: 0.75rem; /* Increased gap for better spacing */
    flex-wrap: wrap;
    align-items: center;
    min-height: 42px; /* Ensure minimum height for buttons */
}

/* ENHANCED BUTTON STYLING FOR ADMIN AREA */
.ticket-tailor-admin .button,
.tt-quick-actions .button,
.ticket-tailor-admin input[type="submit"],
.ticket-tailor-admin .page-title-action {
    border-radius: 6px !important;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.08),
        0 1px 2px rgba(0, 0, 0, 0.06) !important;
    font-size: 14px !important;
    padding: 8px 16px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    text-transform: none !important;
    letter-spacing: 0.3px;
    line-height: 1.5 !important;
    display: inline-block !important;
    flex: 0 0 auto; /* Prevent flex shrinking */
}

/* Primary buttons get special treatment */
.ticket-tailor-admin .button-primary,
.tt-quick-actions .button-primary {
    background: #2271b1 !important;
    border-color: #1e5f9a !important;
    color: #fff !important;
    box-shadow:
        0 2px 4px rgba(34, 113, 177, 0.2),
        0 1px 2px rgba(34, 113, 177, 0.15) !important;
}

.ticket-tailor-admin .button-primary:hover,
.tt-quick-actions .button-primary:hover {
    background: #135e96 !important;
    border-color: #0a4b7c !important;
    box-shadow:
        0 4px 8px rgba(34, 113, 177, 0.25),
        0 2px 4px rgba(34, 113, 177, 0.2) !important;
    transform: translateY(-1px);
}

/* Secondary buttons */
.ticket-tailor-admin .button:not(.button-primary):hover,
.tt-quick-actions .button:not(.button-primary):hover {
    background: #f6f7f7 !important;
    border-color: #8c8f94 !important;
    box-shadow:
        0 3px 6px rgba(0, 0, 0, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.08) !important;
    transform: translateY(-1px);
}

/* Small buttons */
.ticket-tailor-admin .button-small {
    font-size: 13px !important;
    padding: 6px 12px !important;
}

/* Page title actions (like "Sync Events" on the events page) */
.ticket-tailor-admin .page-title-action {
    margin-left: 10px !important;
    vertical-align: middle !important;
}

/* Dashboard Section */
.tt-dashboard-section {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tt-dashboard-section h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: #1d2327;
    border-bottom: 2px solid #f0f0f1;
    padding-bottom: 0.75rem;
}

/* Dashboard Widget */
.tt-dashboard-widget {
    padding: 0;
}

.tt-dashboard-widget h4 {
    margin: 1rem 0 0.5rem;
    font-size: 0.95rem;
    color: #1d2327;
    font-weight: 600;
}

.tt-dashboard-widget ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tt-dashboard-widget li {
    padding: 0.75rem 0;
    border-top: 1px solid #e1e1e1;
}

.tt-dashboard-widget li:first-child {
    border-top: none;
}

.tt-dashboard-widget .description {
    color: #646970;
    font-size: 0.875rem;
}

.tt-dashboard-links {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e1e1e1;
}

/* TABLE STYLES - FIXED CORNERS */
.ticket-tailor-admin .wp-list-table {
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden; /* This ensures border-radius clips content */
    border-collapse: separate; /* Required for border-radius to work */
}

/* Fix for table header background to respect rounded corners */
.ticket-tailor-admin .wp-list-table thead {
    background: #f6f7f7;
}

.ticket-tailor-admin .wp-list-table thead tr:first-child th:first-child {
    border-top-left-radius: 7px;
}

.ticket-tailor-admin .wp-list-table thead tr:first-child th:last-child {
    border-top-right-radius: 7px;
}

/* Fix for table body to respect rounded corners */
.ticket-tailor-admin .wp-list-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 7px;
}

.ticket-tailor-admin .wp-list-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 7px;
}

.ticket-tailor-admin .wp-list-table th {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #2c3338;
    border-bottom: 1px solid #c3c4c7;
}

.ticket-tailor-admin .wp-list-table td {
    padding: 12px 10px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f1;
}

.ticket-tailor-admin .wp-list-table tbody tr:last-child td {
    border-bottom: none;
}

/* Striped table rows */
.ticket-tailor-admin .wp-list-table.striped tbody tr:nth-child(odd) {
    background-color: #f9f9f9;
}

/* Table hover effect */
.ticket-tailor-admin .wp-list-table tbody tr:hover {
    background-color: #f0f6fc;
    transition: background-color 0.2s ease;
}

/* Status Badges */
.tt-status-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tt-status-live,
.tt-status-published,
.tt-status-on_sale {
    background: #d1f4e0;
    color: #0f5132;
}

.tt-status-draft {
    background: #fff3cd;
    color: #856404;
}

.tt-status-archived,
.tt-status-cancelled {
    background: #e2e3e5;
    color: #41464b;
}

.tt-status-completed,
.tt-status-paid {
    background: #cfe2ff;
    color: #084298;
}

.tt-status-pending {
    background: #fff3cd;
    color: #856404;
}

.tt-status-refunded,
.tt-status-sold_out {
    background: #f8d7da;
    color: #721c24;
}

.tt-status-unknown {
    background: #e7e7e7;
    color: #6c757d;
}

/* Help Page Styles */
.tt-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.tt-help-section {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tt-help-section h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #1d2327;
    border-bottom: 2px solid #2271b1;
    padding-bottom: 0.5rem;
}

.tt-help-section h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #50575e;
}

.tt-help-section code {
    display: block;
    padding: 0.75rem;
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.tt-help-section ul,
.tt-help-section ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.tt-help-section li {
    margin-bottom: 0.5rem;
}

/* ENHANCED SETTINGS PAGE STYLING */

/* Override WordPress admin background for settings pages */
.ticket-tailor_page_ticket-tailor-settings {
    background: #f0f2f5 !important;
}

/* Main settings container with white background */
.ticket-tailor_page_ticket-tailor-settings .wrap {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 20px;
    max-width: 1200px;
}

/* Settings page title */
.ticket-tailor_page_ticket-tailor-settings .wrap h1 {
    font-size: 24px;
    color: #1d2327;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f2f5;
}

/* Tab wrapper styling */
.ticket-tailor-admin .nav-tab-wrapper {
    margin-bottom: 2rem;
    border-bottom: none;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 10px;
    display: inline-flex;
    gap: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Individual tab styling - rounded and modern */
.ticket-tailor-admin .nav-tab {
    background: transparent;
    border: none;
    margin: 0;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #50575e;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
}

.ticket-tailor-admin .nav-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    color: #2c3338;
}

/* Active tab styling */
.ticket-tailor-admin .nav-tab-active,
.ticket-tailor-admin .nav-tab-active:focus,
.ticket-tailor-admin .nav-tab-active:hover {
    background: white !important;
    color: #2271b1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: none;
    font-weight: 600;
}

/* Form table improvements */
.ticket-tailor-admin .form-table {
    margin-top: 2rem;
    background: white;
    width: 100%;
}

.ticket-tailor-admin .form-table tr {
    border-bottom: 1px solid #f0f2f5;
}

.ticket-tailor-admin .form-table tr:last-child {
    border-bottom: none;
}

.ticket-tailor-admin .form-table th {
    width: 250px;
    padding: 20px 20px 20px 0;
    font-weight: 600;
    color: #1d2327;
    vertical-align: top;
}

.ticket-tailor-admin .form-table td {
    padding: 20px;
}

.ticket-tailor-admin .form-table .description {
    margin-top: 8px;
    color: #646970;
    font-size: 13px;
    line-height: 1.6;
}

/* Form inputs enhancement */
.ticket-tailor-admin input[type="text"],
.ticket-tailor-admin input[type="number"],
.ticket-tailor-admin select {
    border-radius: 4px;
    border: 1px solid #c3c4c7;
    font-size: 14px;
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.ticket-tailor-admin input[type="text"]:focus,
.ticket-tailor-admin input[type="number"]:focus,
.ticket-tailor-admin select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.08);
}

/* Checkbox styling */
.ticket-tailor-admin input[type="checkbox"] {
    border-radius: 3px;
    margin-right: 8px;
}

/* Code blocks in settings */
.ticket-tailor-admin code {
    background: #f0f2f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: "Monaco", "Courier New", monospace;
    font-size: 13px;
}

/* Submit buttons section */
.ticket-tailor-admin .submit {
    padding: 20px 0;
    margin: 20px 0 0;
    border-top: 2px solid #f0f2f5;
    background: white;
}

/* Cache management section styling */
.ticket-tailor-admin hr {
    border: none;
    border-top: 2px solid #f0f2f5;
    margin: 30px 0;
}

.ticket-tailor-admin h2 {
    font-size: 18px;
    color: #1d2327;
    margin: 30px 0 15px;
}

/* Notice boxes in settings */
.ticket-tailor_page_ticket-tailor-settings .notice {
    border-radius: 8px;
    margin: 15px 0;
    padding: 12px 15px;
    border-left-width: 4px;
}

/* Settings section cards (for Style tab preview, etc.) */
.ticket-tailor-admin .settings-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

/* Live preview section enhancement */
.ticket-tailor-admin h3 {
    font-size: 16px;
    color: #1d2327;
    margin: 25px 0 15px;
    font-weight: 600;
}

/* Colour Picker Enhancements */
.wp-picker-container {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.wp-picker-container .wp-color-result {
    margin-bottom: 0;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    vertical-align: middle;
}

/* Hex value display - styled as inline text label */
.tt-hex-display {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: "Monaco", "Courier New", monospace;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    min-width: 70px;
    text-align: center;
    transition: all 0.2s ease;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Hide the default "Select Color" button text */
.wp-picker-container .wp-color-result .wp-color-result-text {
    display: none;
}

/* Make the colour square more prominent */
.wp-picker-container .wp-color-result {
    width: 40px;
    height: 32px;
    padding: 0;
    border: 2px solid #c3c4c7;
}

.wp-picker-container .wp-color-result:hover {
    border-color: #8c8f94;
}

.wp-picker-container .wp-color-result:after {
    display: none; /* Remove the dropdown arrow */
}

/* Ensure proper alignment in form table */
.ticket-tailor-admin .form-table .wp-picker-container {
    margin-top: 4px;
}

/* Default/Clear button styling - always visible */
.wp-picker-container .wp-picker-clear,
.wp-picker-container .wp-picker-default {
    margin-left: 8px;
    height: 32px;
    line-height: 30px;
    padding: 0 12px !important;
    font-size: 13px;
    border-radius: 4px;
    vertical-align: middle;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #f0f0f1;
    color: #50575e;
    border: 1px solid #c3c4c7;
    text-decoration: none;
    transition: all 0.2s ease;
}

.wp-picker-container .wp-picker-clear:hover,
.wp-picker-container .wp-picker-default:hover {
    background: #e7e7e7;
    border-color: #8c8f94;
    color: #2c3338;
}

/* Ensure the clear button is always shown */
.wp-picker-container.wp-picker-active .wp-picker-clear,
.wp-picker-container:not(.wp-picker-active) .wp-picker-clear {
    display: inline-block !important;
    visibility: visible !important;
}

/* Iris colour picker popup positioning */
.wp-picker-container .wp-picker-holder {
    position: absolute;
    z-index: 100;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

/* Loading States */
.tt-loading {
    text-align: center;
    padding: 2rem;
    color: #646970;
}

.tt-loading::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    border: 2px solid #2271b1;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

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

/* Notice Styles */
.ticket-tailor-admin .notice {
    margin: 1rem 0;
    border-radius: 4px;
}

.ticket-tailor-admin .notice-success {
    border-left-color: #46b450;
}

.ticket-tailor-admin .notice-warning {
    border-left-color: #ffb900;
}

.ticket-tailor-admin .notice-error {
    border-left-color: #dc3232;
}

.ticket-tailor-admin .notice-info {
    border-left-color: #2271b1;
}

/* Filter/Action Bar Above Tables */
.ticket-tailor-admin .tablenav {
    margin: 1rem 0;
}

.ticket-tailor-admin .tablenav select {
    border-radius: 4px;
    font-size: 14px;
    padding: 6px 24px 6px 8px;
    border: 1px solid #8c8f94;
}

/* Responsive Styles */
@media (max-width: 1200px) {
    .tt-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 782px) {
    .tt-stats-grid {
        grid-template-columns: 1fr;
    }

    .tt-help-grid {
        grid-template-columns: 1fr;
    }

    .tt-quick-actions .button-group {
        flex-direction: column;
        align-items: stretch; /* Make buttons full width on mobile */
    }

    .tt-quick-actions .button {
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .tt-quick-actions .button:last-child {
        margin-bottom: 0;
    }

    /* Settings page mobile adjustments */
    .ticket-tailor_page_ticket-tailor-settings .wrap {
        padding: 20px;
        border-radius: 0;
        margin: 0;
    }

    .ticket-tailor-admin .nav-tab-wrapper {
        display: flex;
        flex-direction: column;
        padding: 6px;
        gap: 6px;
    }

    .ticket-tailor-admin .nav-tab {
        display: block;
        text-align: center;
        margin: 0;
        padding: 12px;
        width: 100%;
    }

    .ticket-tailor-admin .form-table th,
    .ticket-tailor-admin .form-table td {
        display: block;
        width: 100%;
        padding: 15px 0;
    }

    .ticket-tailor-admin .form-table th {
        font-weight: 600;
        padding-bottom: 8px;
    }
}

@media (max-width: 600px) {
    .tt-stat-value {
        font-size: 2rem;
    }

    .tt-dashboard-section {
        padding: 1rem;
    }

    .ticket-tailor-admin .wp-list-table {
        font-size: 0.85rem;
    }

    .ticket-tailor-admin .wp-list-table td {
        padding: 8px 5px;
    }

    /* Ensure buttons remain readable on very small screens */
    .ticket-tailor-admin .button {
        font-size: 13px !important;
        padding: 7px 14px !important;
    }
}

/* Accessibility Improvements */
.ticket-tailor-admin a:focus,
.ticket-tailor-admin button:focus,
.ticket-tailor-admin input:focus,
.ticket-tailor-admin select:focus,
.ticket-tailor-admin textarea:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.ticket-tailor-admin .button:focus {
    box-shadow:
        0 0 0 2px #fff,
        0 0 0 4px #2271b1 !important;
}

.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0 !important;
    border: 0 !important;
    height: 1px !important;
    width: 1px !important;
    overflow: hidden;
}

/* Print Styles */
@media print {
    .ticket-tailor-admin .button,
    .ticket-tailor-admin .nav-tab-wrapper,
    .tt-quick-actions {
        display: none;
    }

    .tt-stat-card {
        break-inside: avoid;
    }
}

/* Fix for WordPress admin bar overlap */
.ticket-tailor-admin {
    margin-top: 0;
}

/* Ensure proper spacing in admin area */
.wrap.ticket-tailor-admin {
    margin-right: 20px;
}
