/**
 * Digital Library Custom Styles
 * 
 * @package DigitalLibrary
 * @since 1.0.0
 */

/* Variables */
:root {
    --dl-primary: #0066cc;
    --dl-secondary: #6c757d;
    --dl-success: #28a745;
    --dl-info: #17a2b8;
    --dl-warning: #ffc107;
    --dl-danger: #dc3545;
    --dl-light: #f8f9fa;
    --dl-dark: #343a40;
    --dl-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --dl-font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Global Styles */
body {
    font-family: var(--dl-font-sans);
    line-height: 1.6;
}

/* Header Styles */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.site-branding {
    max-width: 300px;
}

.site-description {
    font-size: 0.875rem;
}

/* Hero Search */
.hero-search {
    background: linear-gradient(135deg, var(--dl-primary) 0%, #004499 100%);
}

.hero-search h1 {
    font-size: 2.5rem;
    font-weight: 300;
}

@media (max-width: 768px) {
    .hero-search h1 {
        font-size: 1.75rem;
    }
}

/* Search Form */
.search-form .form-control {
    border-radius: 0.375rem 0 0 0.375rem;
}

.search-form .btn {
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Resource Cards */
.card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.125);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-title a {
    color: var(--dl-dark);
}

.card-title a:hover {
    color: var(--dl-primary);
}

/* Pagination */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 0.25rem;
    margin: 0 0.125rem;
}

/* WordPress Pagination Override */
.page-numbers {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 0;
    margin: 2rem 0;
    gap: 0.5rem;
}

.page-numbers li {
    margin: 0;
}

.page-numbers a,
.page-numbers span {
    display: inline-block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--dl-primary);
    border: 1px solid var(--dl-primary);
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.page-numbers a:hover {
    background-color: var(--dl-primary);
    color: white;
}

.page-numbers .current {
    background-color: var(--dl-primary);
    color: white;
    border-color: var(--dl-primary);
}

.page-numbers .dots {
    border: none;
    padding: 0.5rem 0.75rem;
}

.page-numbers .prev,
.page-numbers .next {
    font-weight: 500;
}

/* Sidebar Widgets */
.widget {
    margin-bottom: 2rem;
}

.widget-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--dl-primary);
}

/* Footer */
.site-footer {
    margin-top: auto;
}

.footer-widgets .widget {
    color: rgba(255, 255, 255, 0.8);
}

.footer-widgets .widget-title {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

/* Back to Top Button */
#back-to-top {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    opacity: 0.8;
    transition: opacity 0.3s;
}

#back-to-top:hover {
    opacity: 1;
}

/* Login/Register Pages */
.login-page,
.register-page {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
}

.login-form,
.register-form {
    max-width: 400px;
    margin: 0 auto;
}

/* Login Card Styling */
.login-page .card,
.register-page .card {
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.login-page .card-header,
.register-page .card-header {
    background: linear-gradient(135deg, var(--dl-primary) 0%, #004499 100%);
    padding: 2rem;
    border: none;
}

.login-page .card-header h2,
.register-page .card-header h2 {
    font-weight: 300;
    font-size: 1.75rem;
}

.login-page .card-body,
.register-page .card-body {
    padding: 2rem;
}

/* Form Styling */
.login-page .form-control,
.register-page .form-control {
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-color: #dee2e6;
    transition: all 0.3s ease;
}

.login-page .form-control:focus,
.register-page .form-control:focus {
    border-color: var(--dl-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.1);
}

/* Password Toggle Button */
.login-page .input-group .btn-outline-secondary,
.register-page .input-group .btn-outline-secondary {
    border-color: #dee2e6;
    color: #6c757d;
}

.login-page .input-group .btn-outline-secondary:hover,
.register-page .input-group .btn-outline-secondary:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: var(--dl-primary);
}

/* Submit Button */
.login-page .btn-primary.btn-lg,
.register-page .btn-primary.btn-lg {
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    letter-spacing: 0.025em;
    transition: all 0.3s ease;
}

.login-page .btn-primary.btn-lg:hover,
.register-page .btn-primary.btn-lg:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

/* Alert Messages */
.login-page .alert,
.register-page .alert {
    border: none;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
}

.login-page .alert-success,
.register-page .alert-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: #155724;
}

.login-page .alert-danger,
.register-page .alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #721c24;
}

.login-page .alert-info,
.register-page .alert-info {
    background-color: rgba(23, 162, 184, 0.1);
    color: #0c5460;
}

/* Forgot Password Link */
.login-page a,
.register-page a {
    color: var(--dl-primary);
    transition: all 0.3s ease;
}

.login-page a:hover,
.register-page a:hover {
    color: #0056b3;
    text-decoration: none;
}

/* Institution Info */
.login-page .text-muted,
.register-page .text-muted {
    font-size: 0.875rem;
}

/* Modal Styling */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 1.5rem;
}

/* Resource Filters */
.resource-filters {
    background-color: var(--dl-light);
    border-radius: 0.375rem;
    padding: 1.5rem;
}

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

.filter-group:last-child {
    margin-bottom: 0;
}

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

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 0.25rem solid var(--dl-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Accessibility */
.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    word-wrap: normal !important;
}

.screen-reader-text:focus {
    display: block;
    clip: auto !important;
    color: var(--dl-dark);
    background-color: var(--dl-light);
    border-radius: 0.25rem;
    padding: 1rem;
    text-decoration: none;
    font-size: 1rem;
    line-height: normal;
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    z-index: 100000;
}

/* Admin Bar and Language Switcher */
#wpadminbar {
    background: #23282d !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Admin Bar General Improvements */
#wpadminbar .ab-top-menu > li > a,
#wpadminbar .ab-top-menu > li > .ab-item {
    transition: background-color 0.3s ease;
}

#wpadminbar .ab-top-menu > li:hover > a,
#wpadminbar .ab-top-menu > li:hover > .ab-item {
    background: #32373c !important;
}

#wpadminbar .ab-submenu {
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

/* Admin Bar Icons */
#wpadminbar .ab-icon:before {
    font-size: 20px;
    line-height: 1;
}

/* Admin Bar Search */
#wpadminbar #adminbar-search {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    transition: all 0.3s ease;
}

#wpadminbar #adminbar-search:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

/* Language Switcher in Admin Bar */
#wp-admin-bar-language-switcher {
    margin: 0 !important;
}

#wp-admin-bar-language-switcher > a {
    padding: 0 16px !important;
    display: flex;
    align-items: center;
}

#wp-admin-bar-language-switcher .ab-icon {
    font-size: 20px;
    line-height: 20px;
    margin-right: 6px;
}

#wp-admin-bar-language-switcher .ab-label {
    font-weight: 600;
    text-transform: uppercase;
}

#wp-admin-bar-language-switcher-default li > a {
    padding: 0 16px !important;
}

#wp-admin-bar-language-switcher-default li > a:hover {
    background: #32373c !important;
    color: #00b9eb !important;
}

/* Navbar Actions (User Menu & Language Switcher) */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* User Dropdown Button & Login Button */
.navbar-actions .dropdown .btn-outline-primary,
.navbar-actions .btn-primary {
    border-color: var(--dl-primary);
    color: var(--dl-primary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
    background-color: transparent;
}

.navbar-actions .btn-primary {
    background-color: var(--dl-primary);
    color: white;
}

.navbar-actions .dropdown .btn-outline-primary:hover,
.navbar-actions .btn-primary:hover {
    background-color: var(--dl-primary);
    border-color: var(--dl-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.2);
}

.navbar-actions .btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

/* Dropdown Menu Styling */
.navbar-actions .dropdown-menu {
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    padding: 0.5rem 0;
    min-width: 200px;
}

.navbar-actions .dropdown-item {
    padding: 0.5rem 1.25rem;
    transition: background-color 0.2s ease;
    font-weight: 400;
}

.navbar-actions .dropdown-item:hover {
    background-color: var(--dl-light);
    color: var(--dl-primary);
}

.navbar-actions .dropdown-divider {
    margin: 0.5rem 0;
}

/* Language Switcher */
.language-switcher {
    display: inline-flex;
    align-items: center;
}

.language-switcher .btn-outline-secondary {
    border-color: #6c757d;
    color: #6c757d;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    min-width: 3rem;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.language-switcher .btn-outline-secondary:hover {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
}

/* Add flag icons (optional) */
.language-switcher .btn-outline-secondary:before {
    content: "🌐 ";
    font-size: 1rem;
    vertical-align: middle;
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .navbar-actions {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        width: 100%;
        justify-content: flex-start;
    }
    
    .navbar-actions .dropdown,
    .navbar-actions .language-switcher {
        margin-right: 0.5rem;
    }
}

/* Responsive Improvements */
@media (max-width: 768px) {
    /* Mobile Pagination */
    .page-numbers {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .page-numbers a,
    .page-numbers span {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Hide "Previous" and "Next" text on mobile, keep arrows */
    .page-numbers .prev,
    .page-numbers .next {
        font-size: 0;
    }
    
    .page-numbers .prev:before {
        content: "‹";
        font-size: 1.25rem;
    }
    
    .page-numbers .next:after {
        content: "›";
        font-size: 1.25rem;
    }
}

/* Admin Bar Mobile Adjustments */
@media screen and (max-width: 782px) {
    #wpadminbar {
        position: fixed;
    }
    
    #wpadminbar .ab-top-menu > li > a {
        padding: 0 10px;
    }
}

/* Print Styles */
@media print {
    .site-header,
    .site-footer,
    .sidebar,
    .navigation,
    .search-form,
    #back-to-top {
        display: none !important;
    }
    
    .site-content {
        width: 100%;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}