/* =============================================================================
   NewAICodes - Custom Stylesheet (Matching Dashboard Design System)
   ============================================================================= */

/* CSS Variables - Matching dashboard.html */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-bg: #1e293b;
    --light-bg: #f8fafc;
    --white: #ffffff;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Additional variables for components */
    --border-radius: 0.5rem;
    --border-radius-lg: 1rem;
    --transition: all 0.3s ease;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
}

/* =============================================================================
   Base Styles
   ============================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--light-bg);
    min-height: 100vh;
}

/* Selection Styles */
::selection {
    background-color: var(--primary-color);
    color: white;
}

/* Focus Styles */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* =============================================================================
   Typography
   ============================================================================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: 1rem; }
h6 { font-size: var(--font-size-sm); }

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

.text-muted {
    color: var(--text-light);
}

.text-white {
    color: var(--white);
}

.text-center {
    text-align: center;
}

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

.text-left {
    text-align: left;
}

/* =============================================================================
   Layout Utilities
   ============================================================================= */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -1rem;
}

.col {
    flex: 1;
    padding: 0 1rem;
}

.col-2 { flex: 0 0 16.666667%; }
.col-3 { flex: 0 0 25%; }
.col-4 { flex: 0 0 33.333333%; }
.col-6 { flex: 0 0 50%; }
.col-8 { flex: 0 0 66.666667%; }
.col-9 { flex: 0 0 75%; }
.col-12 { flex: 0 0 100%; }

/* Spacing */
.m-0 { margin: 0; }
.m-1 { margin: 0.5rem; }
.m-2 { margin: 1rem; }
.m-3 { margin: 1.5rem; }
.m-4 { margin: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

/* Display */
.d-flex { display: flex; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-none { display: none; }

/* Flex utilities */
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    cursor: pointer;
    text-align: center;
    font-size: var(--font-size-sm);
    background: var(--white);
    color: var(--text-dark);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.btn-primary:hover {
    color: var(--white);
}

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

.btn-secondary:hover {
    background: #475569;
    color: var(--white);
}

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

.btn-success:hover {
    background: #059669;
    color: var(--white);
}

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

.btn-info:hover {
    background: #2563eb;
    color: var(--white);
}

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

.btn-warning:hover {
    background: #d97706;
    color: var(--white);
}

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

.btn-danger:hover {
    background: #dc2626;
    color: var(--white);
}

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

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn-outline-secondary {
    background: transparent;
    border: 2px solid var(--secondary-color);
    color: var(--secondary-color);
}

.btn-outline-secondary:hover {
    background: var(--secondary-color);
    color: var(--white);
}

.btn-small, .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-large, .btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Button Loading State */
.btn.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: button-loading-spinner 1s ease infinite;
}

@keyframes button-loading-spinner {
    from { transform: rotate(0turn); }
    to { transform: rotate(1turn); }
}

/* =============================================================================
   Cards and Components
   ============================================================================= */

.card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 1.5rem;
    border-bottom: none;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: var(--light-bg);
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.card-title {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.card-text {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.card-img-top {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* Software Cards */
.software-card {
    height: 100%;
    cursor: pointer;
    position: relative;
}

.software-card .card-img-top {
    transition: var(--transition);
}

.software-card:hover .card-img-top {
    transform: scale(1.05);
}

.price-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: var(--white);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

/* =============================================================================
   Forms
   ============================================================================= */

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

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
    color: var(--text-dark);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
    color: var(--text-dark);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control.is-invalid {
    border-color: var(--error-color);
}

.form-control.is-valid {
    border-color: var(--success-color);
}

.invalid-feedback {
    color: var(--error-color);
    font-size: var(--font-size-sm);
    margin-top: 0.25rem;
    display: none;
}

.form-control.is-invalid + .invalid-feedback {
    display: block;
}

.valid-feedback {
    color: var(--success-color);
    font-size: var(--font-size-sm);
    margin-top: 0.25rem;
}

/* Input Groups */
.input-group {
    display: flex;
    align-items: stretch;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.input-group .form-control {
    border-radius: 0;
    border-right: none;
}

.input-group-text {
    padding: 0.75rem 1rem;
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-right: none;
    color: var(--text-light);
    display: flex;
    align-items: center;
}

.input-group .btn {
    border-radius: 0;
    border-left: none;
}

/* Checkboxes and Radios */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.5rem;
    accent-color: var(--primary-color);
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* =============================================================================
   Tables
   ============================================================================= */

.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    background: var(--white);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--text-dark);
}

.table tbody tr:hover {
    background: var(--light-bg);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* =============================================================================
   Alerts and Messages
   ============================================================================= */

.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow);
}

/* Flash Messages - Fixed positioning to appear below header */
.flash-messages {
    position: fixed;
    top: 140px !important; /* Position well below the header (header height ~128px + margin) */
    left: 0;
    right: 0;
    z-index: 9999 !important; /* Much higher z-index to ensure visibility */
    padding: 1rem;
    pointer-events: none;
    max-width: 1200px;
    margin: 0 auto;
}

.flash-message {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important; /* Strong shadow for visibility */
    animation: slideDown 0.3s ease-out;
    position: relative;
    pointer-events: auto !important; /* Allow interaction with flash messages */
    z-index: 10000 !important; /* Ensure it's on top */
    /* Make flash messages stay longer */
    animation-duration: 0.3s;
    animation-fill-mode: both;
}

.flash-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid var(--success-color);
}

.flash-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 4px solid var(--error-color);
}

.flash-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

.flash-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left: 4px solid var(--info-color);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.flash-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid var(--success-color);
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 4px solid var(--error-color);
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left: 4px solid var(--info-color);
}

/* =============================================================================
   Dashboard Components
   ============================================================================= */

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

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.stat-number {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--text-dark);
}

.stat-label {
    color: var(--text-light);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

/* =============================================================================
   Navigation and Breadcrumbs
   ============================================================================= */

.breadcrumb {
    display: flex;
    list-style: none;
    background: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.breadcrumb-item {
    color: var(--text-light);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    margin: 0 0.5rem;
    color: var(--text-light);
}

.breadcrumb-item.active {
    color: var(--text-dark);
    font-weight: 500;
}

.breadcrumb-item a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--primary-dark);
}

/* Pagination */
.pagination {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    justify-content: center;
    margin: 2rem 0;
}

.page-item {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.page-link {
    display: block;
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.page-link:hover {
    background: var(--light-bg);
    color: var(--primary-dark);
}

.page-item.active .page-link {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.page-item.disabled .page-link {
    background: var(--light-bg);
    color: var(--text-light);
    cursor: not-allowed;
}

/* =============================================================================
   License and Product Components
   ============================================================================= */

.license-key {
    font-family: 'Courier New', monospace;
    background: var(--light-bg);
    padding: 0.8rem 1rem;
    border-radius: var(--border-radius);
    border: 2px dashed var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.license-key:hover {
    background: var(--primary-color);
    color: var(--white);
}

.license-key .copy-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
}

.license-key .copy-btn:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-inactive {
    background: #fef3c7;
    color: #d97706;
}

.status-pending {
    background: #fefbeb;
    color: #d97706;
}

/* =============================================================================
   Hero and Feature Sections
   ============================================================================= */

.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 4rem 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.5;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

/* Feature Icons */
.feature-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    transition: var(--transition);
}

.feature-card:hover .feature-icon {
    transform: scale(1.1) rotate(5deg);
}

/* =============================================================================
   Loading States and Animations
   ============================================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 1rem;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s ease-in-out infinite;
}

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

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.fade-in {
    animation: fadeIn 0.6s ease forwards;
}

/* =============================================================================
   Utility Classes
   ============================================================================= */

.cursor-pointer { cursor: pointer; }
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-sticky { position: sticky; }
.position-fixed { position: fixed; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.bg-white { background-color: var(--white); }
.bg-light { background-color: var(--light-bg); }
.bg-primary { background-color: var(--primary-color); }
.bg-success { background-color: var(--success-color); }

.border-radius { border-radius: var(--border-radius); }
.border-radius-lg { border-radius: var(--border-radius-lg); }

.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.transition { transition: var(--transition); }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .row {
        margin: 0 -0.5rem;
    }
    
    .col {
        padding: 0 0.5rem;
    }
    
    .col-6, .col-4, .col-3, .col-2 {
        flex: 0 0 100%;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .feature-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
        font-size: var(--font-size-sm);
    }
}

@media (max-width: 576px) {
    .hero-section {
        padding: 2rem 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .license-key {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }
    
    .pagination {
        gap: 0.25rem;
    }
    
    .page-link {
        padding: 0.375rem 0.75rem;
        font-size: var(--font-size-sm);
    }
}

.logo::before {
    display: none;
}