/**
 * Main Theme Styles
 * Common styles for all templates
 */

@import url('variables.css');
@import url('components.css');
@import url('search-common.css');

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* WordPress Admin Bar Compatibility */
body.admin-bar .ms-header {
    top: var(--admin-bar-height, 0);
}

body.admin-bar .ms-sidebar {
    top: calc(var(--header-height) + var(--admin-bar-height, 0));
    height: calc(100vh - var(--header-height) - var(--admin-bar-height, 0));
}

/* Links */
a {
    color: var(--ms-blue-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 var(--spacing-md);
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: var(--font-size-xxxl); }
h2 { font-size: var(--font-size-xxl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* Screen Reader Text */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Buttons */
button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

.button,
.wp-block-button__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: var(--font-size-base);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.button-primary {
    background-color: var(--ms-blue-dark);
    color: white;
}

.button-primary:hover {
    background-color: #106EBE;
    text-decoration: none;
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-family: inherit;
    font-size: var(--font-size-base);
    background-color: var(--surface);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--ms-blue-dark);
    box-shadow: 0 0 0 1px var(--ms-blue-dark);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }
.mt-5 { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }
.mb-5 { margin-bottom: var(--spacing-xl); }

/* Hide/Show Based on Theme */
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-medium), visibility var(--transition-medium);
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile First Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-md);
    }
    
    h1 { font-size: var(--font-size-xxl); }
    h2 { font-size: var(--font-size-xl); }
    h3 { font-size: var(--font-size-lg); }
}

/* Alert Messages */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 4px;
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

.alert-warning {
    background-color: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFB74D;
}

.alert-info {
    background-color: #E3F2FD;
    color: #0D47A1;
    border: 1px solid #64B5F6;
}

.alert-success {
    background-color: #E8F5E9;
    color: #1B5E20;
    border: 1px solid #66BB6A;
}

.alert-error {
    background-color: #FFEBEE;
    color: #B71C1C;
    border: 1px solid #EF5350;
}

/* Skip Link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 2.5rem;
    z-index: 999999;
    text-decoration: underline;
}

.skip-link:focus {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 2.5rem;
    z-index: 999999;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--surface);
    border: 2px solid var(--ms-blue-dark);
    border-radius: 4px;
    color: var(--ms-blue-dark);
    font-weight: 600;
}

/* WordPress Block Compatibility */
.wp-block-group,
.wp-block-columns,
.wp-block-column {
    margin: 0;
}

/* Site Footer - Minimal */
.site-footer {
    position: relative;
    background: #F3F2F1;
    border-top: 1px solid #E1DFDD;
    z-index: var(--z-footer);
    height: 32px;
    margin-top: auto;
}

.footer-minimal {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.footer-text {
    font-size: 12px;
    color: #8A8886;
    text-align: center;
}

/* Make page container flex to push footer down */
#page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--ms-blue-dark);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Profile Button and Dropdown - Global Styles */
.profile-button {
    position: relative;
    cursor: pointer;
}

.profile-button .profile-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00BCF2 0%, #0078D4 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.profile-button .profile-initials.has-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Profile Dropdown */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background-color: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.profile-button:hover .profile-dropdown,
.profile-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00BCF2 0%, #0078D4 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-email {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-dropdown-divider {
    height: 1px;
    background-color: var(--border-subtle);
}

.profile-dropdown-menu {
    padding: 8px 0;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.1s ease;
}

.profile-dropdown-item:hover {
    background-color: var(--hover-light);
}

.profile-dropdown-item i {
    font-size: 16px;
    color: var(--text-secondary);
    width: 20px;
}

/* Trial Banner - Smart Agency Style */
.trial-banner {
    position: sticky;
    top: 0;
    z-index: 999;
    background: #E7F1FA;
    border-bottom: 1px solid #d2d0ce;
    animation: slideDown 0.3s ease;
    margin-bottom: -54px;
}

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

.trial-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 8px 32px;
    max-width: 1400px;
    margin: 0 auto;
    margin-top: 49px !important;
}

/* Compact Info */
.trial-info-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    line-height: 1;
}

.trial-info-compact .ms-Icon {
    font-size: 16px;
    color: #0078d4;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.trial-info-compact strong {
    font-weight: 600;
    color: #323130;
}

.trial-separator {
    color: #8a8886;
    font-weight: 400;
}

.trial-countdown {
    font-size: 13px;
    font-weight: 500;
    color: #605E5C;
}

/* Warning State - 7 days or less */
.trial-banner.trial-warning {
    background: #FFF9E6;
    border-bottom-color: #e0d4b0;
}

.trial-banner.trial-warning .trial-info-compact .ms-Icon {
    color: #d68910;
}

.trial-banner.trial-warning .trial-countdown {
    color: #d68910;
    font-weight: 600;
}

/* Urgent State - 3 days or less */
.trial-banner.trial-urgent {
    background: #FFEBEE;
    border-bottom-color: #e5c5c9;
    animation: pulseWarning 2s ease-in-out infinite;
}

@keyframes pulseWarning {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.95;
    }
}

.trial-banner.trial-urgent .trial-info-compact .ms-Icon {
    color: #E74856;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-3px);
    }
    75% {
        transform: translateX(3px);
    }
}

.trial-banner.trial-urgent .trial-countdown {
    color: #E74856;
    font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .trial-banner-content {
        padding: 10px 16px;
    }

    .trial-info-compact {
        font-size: 12px;
        gap: 8px;
    }

    .trial-info-compact .ms-Icon {
        font-size: 14px;
    }
}